public int UpdateEvent(EventModel obj) { int result = 0; CheckForLocation_Event(ref obj, obj); using (RSEntities objEnt = new RSEntities()) { var oData = objEnt.RS_Event.Where(i => i.EventId == obj.EventId).First(); oData.EventType = obj.EventType; oData.Subject = obj.Subject; oData.Body = obj.Body; oData.EventDateFrom = obj.EventDateFrom; oData.EventTimeFrom = obj.EventTimeFrom; oData.EventDateTo = obj.EventDateTo; oData.EventTimeTo = obj.EventTimeTo; oData.Location = obj.LocationName; oData.District = obj.DistrictName; oData.ModifiedBy = obj.ModifiedBy; oData.ModifiedOn = DateTime.Now; oData.IsActive = true; result = objEnt.SaveChanges(); } return(result); }
private EventModel CheckForLocation_Event(ref EventModel result, EventModel obj) { RS_EventType EventTypeResult = new RS_EventType(); using (RSEntities objEnt = new RSEntities()) { if (obj.EventTypeName.Trim() != string.Empty) { /// Checking for current location present or not var EventType = objEnt.RS_EventType.Where(o => o.EventType.Trim().ToUpper() == obj.EventTypeName.Trim().ToUpper()); if (EventType.Count() > 0) { EventTypeResult = EventType.FirstOrDefault(); } else { RS_EventType oData = new RS_EventType(); oData.EventType = obj.EventTypeName; oData.CreatedOn = DateTime.Now; oData.CreatedBy = obj.CreatedBy; objEnt.RS_EventType.Add(oData); objEnt.SaveChanges(); EventTypeResult = oData; } } result.EventType = EventTypeResult != null && EventTypeResult.EventTypeId != 0 ? EventTypeResult.EventTypeId : (int?)null; } return(result); }
public int InsertEvent(EventModel obj) { int result = 0; CheckForLocation_Event(ref obj, obj); using (RSEntities objEnt = new RSEntities()) { RS_Event oData = new RS_Event(); oData.EventType = obj.EventType; oData.Subject = obj.Subject; oData.Body = obj.Body; oData.EventDateFrom = obj.EventDateFrom; oData.EventTimeFrom = obj.EventTimeFrom; oData.EventDateTo = obj.EventDateTo; oData.EventTimeTo = obj.EventTimeTo; oData.Location = obj.LocationName; oData.District = obj.DistrictName; oData.CreatedBy = obj.CreatedBy; oData.CreatedOn = DateTime.Now; oData.IsActive = true; //oData.CreatedOn = ; //oData.Location = obj.Location; //oData.IpAddress = obj.IpAddress; objEnt.RS_Event.Add(oData); result = objEnt.SaveChanges(); } return(result); }
public int UpdateRathoreDetail(RathoreDetailModel obj) { int result = 0; using (RSEntities objEnt = new RSEntities()) { CheckForCurrentLocationDetail(ref obj, obj); CheckForNativeLocationDetail(ref obj, obj); var oData = objEnt.RS_RathoreDetails.Where(i => i.RathoreDetailId == obj.RathoreDetailId).First(); oData.Name = obj.Name; oData.FatherName = obj.FatherName; oData.MotherName = obj.MotherName; oData.DateOfBirth = obj.DateOfBirth; oData.PhoneNumber = obj.PhoneNumber; oData.Occupation = obj.Occupation; oData.gender = obj.Gender; oData.IsMarried = obj.IsMarried; oData.SpouseName = obj.SpouseName; oData.CurrentCountry = obj.CurrentCountry; oData.CurrentState = obj.CurrentState; oData.CurrentDistrict = obj.CurrentDistrict; oData.CurrentLocation = obj.CurrentLocation; oData.CurrentAddress = obj.CurrentAddress; oData.NativeCountry = obj.NativeCountry; oData.NativeState = obj.NativeState; oData.NativeDistrict = obj.NativeDistrict; oData.NativeLocation = obj.NativeLocation; oData.NativeAddress = obj.NativeAddress; oData.EmailId = obj.EmailId; oData.FinalEducation = obj.FinalEducation; oData.NoOfChildern = obj.NoOfChildern; oData.ModifiedBy = obj.ModifiedBy; oData.ModifiedOn = DateTime.Now; oData.IsActive = true; oData.UserName = obj.UserName; oData.Password = obj.Password; oData.Role = obj.Role; //oData.CreatedOn = ; //oData.Location = obj.Location; //oData.IpAddress = obj.IpAddress; //objEnt.RS_RathoreDetails.Add(oData); result = objEnt.SaveChanges(); } return(result); }
public int DeleteContact(int Id) { int result = 0; using (RSEntities obj = new RSEntities()) { var oSelect = obj.RS_ContactUs.First(i => i.ContactusId == Id); obj.RS_ContactUs.Remove(oSelect); result = obj.SaveChanges(); } return(result); }
public int DeleteRathoreDetail(int rathoreDetailId) { int result = 0; using (RSEntities obj = new RSEntities()) { var oSelect = obj.RS_RathoreDetails.First(i => i.RathoreDetailId == rathoreDetailId); obj.RS_RathoreDetails.Remove(oSelect); result = obj.SaveChanges(); } return(result); }
public int DeleteEvent(int Id) { int result = 0; using (RSEntities obj = new RSEntities()) { var oSelect = obj.RS_Event.First(i => i.EventId == Id); obj.RS_Event.Remove(oSelect); result = obj.SaveChanges(); } return(result); }
/// <summary> /// Update the login detail information /// </summary> /// <param name="lm"></param> /// <returns></returns> public int UpdateLoginInfoDetail(LoginModel lm) { int result = 0; using (RSEntities obj = new RSEntities()) { var oData = obj.RS_RathoreDetails.First(i => i.RathoreDetailId == lm.RathoreDetailId); oData.LastLogin = DateTime.Now; oData.LoginCount = oData.LoginCount == null ? 1 : oData.LoginCount + 1; oData.ModifiedOn = DateTime.Now; oData.ModifiedBy = lm.RathoreDetailId; result = obj.SaveChanges(); } return(result); }
public int InsertContact(ContactModel obj) { int result = 0; using (RSEntities objEnt = new RSEntities()) { RS_ContactUs oData = new RS_ContactUs(); oData.Name = obj.Name; oData.PhoneNumber = obj.PhoneNumber; oData.EmailId = obj.EmailId; oData.Body = obj.Body; oData.Subject = obj.Subject; oData.CreatedOn = DateTime.Now; oData.Location = obj.Location; oData.IpAddress = obj.IpAddress; objEnt.RS_ContactUs.Add(oData); result = objEnt.SaveChanges(); } return(result); }
private RathoreDetailModel CheckForNativeLocationDetail(ref RathoreDetailModel result, RathoreDetailModel obj) { RS_Country NativeCountryResult = new RS_Country(); RS_State NativeStateResult = new RS_State(); RS_District NativeDistrictResult = new RS_District(); RS_Location NativeLocationResult = new RS_Location(); using (RSEntities objEnt = new RSEntities()) { if (obj.NativeCountryName.Trim() != string.Empty) { //// Checking that current inserted country is present or not var CurrentCountry = objEnt.RS_Country.Where(o => o.CountryName.Trim().ToUpper() == obj.NativeCountryName.Trim().ToUpper()); if (CurrentCountry.Count() > 0) { NativeCountryResult = CurrentCountry.FirstOrDefault(); } else { RS_Country oData = new RS_Country(); oData.CountryName = obj.NativeCountryName; oData.CreatedOn = DateTime.Now; oData.CreatedBy = obj.CreatedBy; objEnt.RS_Country.Add(oData); objEnt.SaveChanges(); NativeCountryResult = oData; result.CurrentCountry = NativeCountryResult.CountryId; } } result.NativeCountry = NativeCountryResult != null && NativeCountryResult.CountryId != 0 ? NativeCountryResult.CountryId : (int?)null; } using (RSEntities objEnt = new RSEntities()) { if (obj.NativeStateName.Trim() != string.Empty) { /// Checking for current state is present or nor var CurrentState = objEnt.RS_State.Where(o => o.StateName.Trim().ToUpper() == obj.NativeStateName.Trim().ToUpper()); if (CurrentState.Count() > 0) { NativeStateResult = CurrentState.FirstOrDefault(); } else { RS_State oData = new RS_State(); oData.CountryId = NativeCountryResult.CountryId; oData.StateName = obj.NativeStateName; oData.CreatedOn = DateTime.Now; oData.CreatedBy = obj.CreatedBy; objEnt.RS_State.Add(oData); objEnt.SaveChanges(); NativeStateResult = oData; } } result.NativeState = NativeStateResult != null && NativeStateResult.StateId != 0 ? NativeStateResult.StateId : (int?)null; } using (RSEntities objEnt = new RSEntities()) { if (obj.NativeDistrictName.Trim() != string.Empty) { /// Checking for current district present or not var CurrentDistrict = objEnt.RS_District.Where(o => o.DistrictName.Trim().ToUpper() == obj.NativeDistrictName.Trim().ToUpper()); if (CurrentDistrict.Count() > 0) { NativeDistrictResult = CurrentDistrict.FirstOrDefault(); } else { RS_District oData = new RS_District(); oData.DistrictName = obj.NativeDistrictName; oData.StateId = NativeStateResult.StateId; oData.CreatedOn = DateTime.Now; oData.CreatedBy = obj.CreatedBy; objEnt.RS_District.Add(oData); objEnt.SaveChanges(); NativeDistrictResult = oData; } } result.NativeDistrict = NativeDistrictResult != null && NativeDistrictResult.DistrictId != 0 ? NativeDistrictResult.DistrictId : (int?)null; } using (RSEntities objEnt = new RSEntities()) { if (obj.NativeLocationName.Trim() != string.Empty) { /// Checking for current location present or not var CurrentLocation = objEnt.RS_Location.Where(o => o.LocationName.Trim().ToUpper() == obj.NativeLocationName.Trim().ToUpper()); if (CurrentLocation.Count() > 0) { NativeLocationResult = CurrentLocation.FirstOrDefault(); } else { RS_Location oData = new RS_Location(); oData.LocationName = obj.NativeLocationName; oData.DistrictId = NativeDistrictResult.DistrictId; oData.CreatedOn = DateTime.Now; oData.CreatedBy = obj.CreatedBy; objEnt.RS_Location.Add(oData); objEnt.SaveChanges(); NativeLocationResult = oData; } } result.NativeLocation = NativeLocationResult != null && NativeLocationResult.LocationId != 0 ? NativeLocationResult.LocationId : (int?)null; } return(result); }