示例#1
0
        public int SavePlanner(PlannerModel model)
        {
            model.CreatedDate = DateTime.Now;
            var plannerEntity = Mapper.DynamicMap <tblPlanner>(model);

            _plannerRepository.Add(plannerEntity);
            return(_plannerRepository.SaveChanges());
        }
示例#2
0
        public IActionResult Put(string id, [FromBody] PlannerModel titleIn)
        {
            var title = _plannerService.Get(id);

            if (title == null)
            {
                return(NotFound());
            }

            _plannerService.Update(id, titleIn);

            return(NoContent());
        }
示例#3
0
        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);
        }
示例#4
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());
        }
示例#5
0
 // 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);
 }
示例#9
0
 public ActionResult <PlannerModel> Post([FromBody] PlannerModel title)
 {
     _plannerService.Create(title);
     return(CreatedAtRoute("", new { id = title.Id.ToString() }, title));
 }