Exemplo n.º 1
0
        public async Task <bool> UpdateWorkPlan(DTOWorkPlan workPlan)
        {
            WorkPlan mapWorkPlan = _mapper.Map <WorkPlan>(workPlan);

            _workPlanRepository.Update(mapWorkPlan);

            bool success = true;

            try
            {
                await _workPlanRepository.SaveChanges();
            }
            catch
            {
                if (!_workPlanRepository.WorkPlanExists(workPlan.WorkPlanID))
                {
                    success = false;
                }
                else
                {
                    throw;
                }
            }

            return(success);
        }
Exemplo n.º 2
0
        public async Task <bool> AddWorkPlan(DTOWorkPlan workPlan)
        {
            WorkPlan mapWorkPlan = _mapper.Map <WorkPlan>(workPlan);

            _workPlanRepository.Add(mapWorkPlan);
            bool success = true;

            try
            {
                await _workPlanRepository.SaveChanges();
            }
            catch
            {
                success = false;
            }

            return(success);
        }
Exemplo n.º 3
0
        public async Task <IHttpActionResult> PostWorkPlan(DTOWorkPlan dto)
        {
            WorkPlan workPlan = new WorkPlan
            {
                ItemId         = dto.ItemId,
                WorkPlanRecord = new WorkPlanRecord
                {
                    Value  = dto.Value,
                    UnitId = dto.UnitId
                }
            };

            db.WorkPlans.Add(workPlan);
            await db.SaveChangesAsync();

            Item item = await db.Items.FindAsync(dto.ItemId);

            int sum = await InsertWorkOrder(workPlan.Id.ToString(), item, 1);

            return(Ok(sum));
        }