public int SavePlanner(PlannerModel model) { model.CreatedDate = DateTime.Now; var plannerEntity = Mapper.DynamicMap <tblPlanner>(model); _plannerRepository.Add(plannerEntity); return(_plannerRepository.SaveChanges()); }
public IActionResult Put(string id, [FromBody] PlannerModel titleIn) { var title = _plannerService.Get(id); if (title == null) { return(NotFound()); } _plannerService.Update(id, titleIn); return(NoContent()); }
public int UpdatePlanner(PlannerModel model) { var planner = _plannerRepository.Find(x => x.PlannerID == model.PlannerID).FirstOrDefault(); if (planner != null) { model.LastUpdatedDate = DateTime.Now; Mapper.CreateMap <PlannerModel, tblPlanner>() .ForMember(dest => dest.PlannerID, opt => opt.Ignore()); // ignore primary key while update/delete tblPlanner plannerEntity = (tblPlanner)Mapper.Map(model, planner); return(_plannerRepository.SaveChanges()); } return(0); }
public async Task <IActionResult> Create(PlannerModel model) { if (model == null) { return(BadRequest()); } _context.DataPlanners.Add(new DataPlanner { Title = model.Title, Description = model.Description, startTodo = model.startTodo, dueTodo = model.dueTodo }); await _context.SaveChangesAsync(); return(Ok()); }
// PUT api/<controller>/5 public int Put([FromBody] PlannerModel model) { if (model.EmpID == null || model.EmpID == 0) { model.EmpID = int.Parse(base.UserIdentity); model.DepartmentId = DepartmentId; model.LocationId = LocationId; } else { // TODO when selected employee change then assign dept id based on selected empid model.DepartmentId = _plannerService.GetDepartmentId(model.EmpID.Value); model.LocationId = _plannerService.GetLocationByEmployeeId(model.EmpID.Value); } model.Status = true; model.LastUpdatedBy = UserName; return(_plannerService.UpdatePlanner(model)); }
public void Delete(PlannerModel plannerIn) => _planners.DeleteOne(planner => planner.Id == plannerIn.Id);
public void Update(string id, PlannerModel plannerIn) => _planners.ReplaceOne(planner => planner.Id == id, plannerIn);
public PlannerModel Create(PlannerModel planner) { _planners.InsertOne(planner); return(planner); }
public ActionResult <PlannerModel> Post([FromBody] PlannerModel title) { _plannerService.Create(title); return(CreatedAtRoute("", new { id = title.Id.ToString() }, title)); }