public ResponseOut UpdatePlans(PlansViewModel model) { ResponseOut responseOut = new ResponseOut(); try { using (PortalEntities _context = new PortalEntities()) { portal_plan plan = _context.portal_plan.Where(x => x.pk_plan_type_id == model.pk_plan_id).FirstOrDefault(); plan.is_active = model.is_active; plan.is_deleted = false; plan.plan_name = model.plan_name; int result = _context.SaveChanges(); if (result > 0) { responseOut.status = ActionStatus.Success; responseOut.message = ActionMessage.PlansCreatedSuccess; } } } catch (Exception ex) { responseOut.status = ActionStatus.Fail; responseOut.message = ActionMessage.ApplicationException; } return(responseOut); }
public ResponseOut AddPlans(PlansViewModel model) { ResponseOut responseOut = new ResponseOut(); try { using (PortalEntities _context = new PortalEntities()) { portal_plan plan = new portal_plan(); plan.is_active = model.is_active; plan.is_deleted = false; plan.plan_name = model.plan_name; _context.portal_plan.Add(plan); int result = _context.SaveChanges(); if (result > 0) { responseOut.status = ActionStatus.Success; responseOut.message = ActionMessage.PlansCreatedSuccess; } } } catch (Exception ex) { responseOut.status = ActionStatus.Fail; responseOut.message = ActionMessage.ApplicationException; } return(responseOut); }