public StateVM EditState(StateVM c) { DB.tblState State = IMSDB.tblStates.Find(c.StateId); if (State != null) { State.StateName = c.StateName; State.CountryId = c.Country.CountryId; //State.StateCode = c.StateCode; State.IsActive = c.IsActive; IMSDB.Entry(State).State = EntityState.Modified; IMSDB.SaveChanges(); } return(c); }
public StateVM AddState(StateVM c) { DB.tblState State = IMSDB.tblStates.Add( new DB.tblState { //StateCode = c.StateCode, StateName = c.StateName, CountryId = c.Country.CountryId, IsActive = c.IsActive }); IMSDB.SaveChanges(); c.StateId = State.StateId; return(c); }
public StateVM GetStateById(int StateId) { DB.tblState State = IMSDB.tblStates.Where(p => p.StateId == StateId).FirstOrDefault(); if (State != null) { return(new StateVM() { StateId = State.StateId, StateName = State.StateName, //StateCode = State.StateCode, Country = new CountryVM { CountryId = State.tblCountry.CountryId, CountryCode = State.tblCountry.CountryCode, CountryName = State.tblCountry.CountryName, IsActive = State.tblCountry.IsActive }, IsActive = State.IsActive }); } return(null); }