public ServiceResponse Save(TrainingInquiryModel model) { try { using (var ts = new TransactionScope(TransactionScopeOption.Required)) { Core_TrainingSession obj = new Core_TrainingSession { FullName = model.FullName, CompanyName = model.CompanyName, EmailAddress = model.EmailAddress, ContactNo = model.ContactNo, IsAgent = model.IsAgent, ObjectiveOfTraning = model.ObjectiveOfTraning, PreferredDay = model.PreferredDay, PrefferedTime = model.PrefferedTime, Remarks = model.Remarks, }; _ent.AddToCore_TrainingSession(obj); _ent.SaveChanges(); ts.Complete(); _response = new ServiceResponse("Record successfully created!!", MessageType.Success, true, "Edit"); return(_response); } } catch (SqlException ex) { _response = new ServiceResponse(ServiceResponsesProvider.SqlExceptionMessage(ex), MessageType.SqlException, false); } catch (Exception ex) { _response = new ServiceResponse(ex.Message, MessageType.Exception, false, "Edit"); } return(_response); }
public App_Class.ServiceResponse Delete(int PId) { Core_TrainingSession result = _ent.Core_TrainingSession.Where(x => x.TrainingSessionId == PId).FirstOrDefault(); try { _ent.DeleteObject(result); _ent.SaveChanges(); _response = new ServiceResponse("Successfully deleted!!", MessageType.Success, true, "Delete"); return(_response); } catch (SqlException ex) { _response = new ServiceResponse(ServiceResponsesProvider.SqlExceptionMessage(ex), MessageType.SqlException, false); } catch (Exception ex) { _response = new ServiceResponse(ex.Message, MessageType.Exception, false, "Delete"); } return(_response); }