public static void AddWorkprogress(this tbl_workprogress workprogress, JunctionViewModel junctionVm)
 {
     workprogress.project_id       = junctionVm.project_id;
     workprogress.ps_id            = junctionVm.ps_id;
     workprogress.subcontractor_id = 0;
     workprogress.update_date      = DateTime.Now;
 }
 public static void AddWorkprogress(this tbl_workprogress workprogress, WorkProgressViewModel workprogressVm)
 {
     //workprogress.ps_id = workprogressVm.ps_id;
     //workprogress.junction_name = workprogressVm.junction_name;
     //workprogress.poles_total = workprogressVm.poles_total;
     //workprogress.ps_id = workprogressVm.ps_id;
     //workprogress.ps_id = workprogressVm.ps_id;
 }
 public HttpResponseMessage SaveWorkprogress(HttpRequestMessage request, WorkProgressViewModel workprogress)
 {
     return(CreateHttpResponse(request, () =>
     {
         HttpResponseMessage response = null;
         if (!ModelState.IsValid)
         {
             response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
         }
         else
         {
             tbl_workprogress newWorkprogress = new tbl_workprogress();
             newWorkprogress.AddWorkprogress(workprogress);
             //_workprogressRepository.Add(AddWorkprogress);
             _unitOfWork.Commit();
             //response = request.CreateResponse<SubContractorViewModel>(HttpStatusCode.Created, workprogress);
         }
         return response;
     }));
 }
예제 #4
0
        public HttpResponseMessage SaveJunction(HttpRequestMessage request, JunctionViewModel junction)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    tbl_junction newJunction = new tbl_junction();
                    newJunction.AddJunction(junction);
                    for (var i = 0; i < junction.junComponents.Count; i++)
                    {
                        var newJunComponent = new tbl_junctionComponents();
                        newJunComponent.tenant_id = junction.tenant_id;
                        newJunComponent.project_id = newJunction.project_id;
                        newJunComponent.junction_id = newJunction.id;
                        newJunComponent.component = junction.junComponents[i].component;
                        newJunComponent.quantity = junction.junComponents[i].quantity;
                        newJunction.junComponents.Add(newJunComponent);
                    }
                    _junctionRepository.Add(newJunction);
                    _unitOfWork.Commit();

                    for (var i = 0; i < junction.junComponents.Count; i++)
                    {
                        tbl_workprogress newworkprogress = new tbl_workprogress();
                        newworkprogress.tenant_id = junction.tenant_id;
                        newworkprogress.junction_id = newJunction.id;
                        newworkprogress.AddWorkprogress(junction);
                        newworkprogress.jun_component = junction.junComponents[i].component;
                        newworkprogress.total = junction.junComponents[i].quantity;
                        newworkprogress.completed = 0;
                        newworkprogress.pending = 0;
                        newworkprogress.progress = 0;
                        _workprogressRepository.Add(newworkprogress);

                        tbl_workverification newworkverification = new tbl_workverification();
                        newworkverification.tenant_id = junction.tenant_id;
                        newworkverification.project_id = junction.project_id;
                        newworkverification.ps_id = junction.ps_id;
                        newworkverification.junction_id = newJunction.id;
                        newworkverification.subcontractor_id = 0;
                        newworkverification.assigned_date = DateTime.Now;
                        newworkverification.jun_component = junction.junComponents[i].component;
                        newworkverification.total = junction.junComponents[i].quantity;
                        newworkverification.completed = 0;
                        newworkverification.verified_by = 0;
                        newworkverification.verification_status = 0;
                        newworkverification.verified_quantity = 0;
                        newworkverification.nc_quantity = 0;
                        newworkverification.created_date = DateTime.Now;
                        _workverificationRepository.Add(newworkverification);

                        _unitOfWork.Commit();
                    }
                    response = request.CreateResponse <JunctionViewModel>(HttpStatusCode.Created, junction);
                }
                return response;
            }));
        }