0

My application is huge and after one year we've found that customers "like" inserting whitespaces in their names or surnames... Is there any simple way to remove whitespaces from those strings (and not searching for every line in program) or I have to search my whole code and change every line which sets Osoba? Wanted to do set { Osoba = value.Trim(): } but I also had to assign get which I can't do in model's property.

public class Event
    {
        [Key]
        public int EventID { get; set; }

        public DateTime AddTime { get; set; }

        public DateTime Start { get; set; }

        public DateTime End { get; set; }

        public EventCreateType EventCreateType { get; set; }

        public EventStatus Status { get; set; }

        public string Osoba { get; set; }

        (...)
    } 
13
  • Use String.Trim() inside the http post action method which handles the form submit and save the trimmed data to database Commented May 30, 2018 at 16:47
  • That's the point, but what if there are 100 http post actions? Is there any simple way? Commented May 30, 2018 at 16:48
  • Write helper methods for each of them. For example : Each view model may have a method called TrimValues() which trims it's property values. Commented May 30, 2018 at 16:49
  • You wants to change the old data or the new data which is going to be inserted in db? Commented May 30, 2018 at 16:49
  • 1
    Since it is an asp.net mvc application, have a look at stackoverflow.com/questions/1718501/…; they implemented the trim via a modelbinder, meaning at the moment the posted text gets assigned to the viewmodel. Commented May 30, 2018 at 17:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.