public ServiceResponse Edit(AirOfflineSettingModel model) { using (var ts = new TransactionScope(TransactionScopeOption.Required)) { try { foreach (var item in model.AirlineList) { var result = _entity.Air_OffLineAirlineSettings.Where(x => x.OfflineAirlineSettingId == item.PId).FirstOrDefault(); if (result != null) { result.IsOffline = item.IsOffline; _entity.ApplyCurrentValues(result.EntityKey.EntitySetName, result); _entity.SaveChanges(); } } ts.Complete(); _response = new ServiceResponse("Record successfully created!!", MessageType.Success, true, "Edit"); } catch (Exception ex) { _response = new ServiceResponse("Error occured while editing record!!", MessageType.Warning, false, "Edit"); return(_response); } return(_response); } }
public AirOfflineSettingModel GetOfflineAirlineById(int id) { // var detail = _entity.air_off var model = new AirOfflineSettingModel(); model.AirlineCode = "9W"; model.AirlineId = 1; model.AirlineName = "Jet Airways"; return(model); }
public ServiceResponse Save(AirOfflineSettingModel model) { try { using (var ts = new TransactionScope(TransactionScopeOption.Required)) { foreach (var data in model.AirlineList) { var result = _entity.Air_OffLineAirlineSettings.Where(x => x.AirlineId == data.AirlineId).FirstOrDefault(); if (result != null) { result.IsOffline = data.IsOffline; _entity.ApplyCurrentValues(result.EntityKey.EntitySetName, result); _entity.SaveChanges(); } else { var setting = new Air_OffLineAirlineSettings() { AirlineId = data.AirlineId, ServiceProviderId = 5, IsOffline = data.IsOffline, CreatedBy = 1, CreatedDate = DateTime.Now }; _entity.AddToAir_OffLineAirlineSettings(setting); _entity.SaveChanges(); } } ts.Complete(); _response = new ServiceResponse("Record successfully created!!", MessageType.Success, true, "Edit"); return(_response); } } catch (Exception ex) { _response = new ServiceResponse(ex.Message, MessageType.Exception, false, "Edit"); return(_response); } }
public List <AirOfflineSettingModel> GetOfflineAirlineList() { var list = new List <AirOfflineSettingModel>(); if (_entity.Air_OffLineAirlineSettings.Count() > 0) { foreach (var data in _entity.Air_OffLineAirlineSettings) { var airlineData = GetAirlineById(data.AirlineId); var airline = new AirOfflineSettingModel() { PId = data.OfflineAirlineSettingId, AirlineId = data.AirlineId, IsOffline = data.IsOffline, AirlineName = airlineData.AirlineName, AirlineCode = airlineData.AirlineCode }; list.Add(airline); } } return(list); }
public ServiceResponse ActionSaveUpdate(AirOfflineSettingModel model, string tranMode) { try { if (tranMode == "N") { return(Save(model)); } else if (tranMode == "U") { return(Edit(model)); } } catch (SqlException ex) { _response = new ServiceResponse(ServiceResponsesProvider.SqlExceptionMessage(ex), MessageType.SqlException, false); } catch (Exception ex) { _response = new ServiceResponse(ex.Message, MessageType.Exception, false); } return(_response); }
public ActionResult Edit(AirOfflineSettingModel model) { return(new EmptyResult()); }
public ActionResult Create(AirOfflineSettingModel model) { provider.Save(model); return(View(model)); }
public ActionResult Index(AirOfflineSettingModel model) { provider.ActionSaveUpdate(model, "U"); return(RedirectToAction("Index")); }