Esempio n. 1
0
        public ResponseMessage AddStructureCost(ADDStructureCost input)
        {
            try
            {
                ResponseMessage  responseMessage = new ResponseMessage();
                ProjectStructure structid        =
                    _context.ProjectStructure.Single(w => w.Id == input.ProjectStructureId);
                DispReqStructure dispstructid =
                    _context.DispReqStructure.Single(w => w.ProjStructId == input.ProjectStructureId);

                dispstructid.FabriacationCost = input.Cost;
                DispFabricationCost fabrcost = new DispFabricationCost();
                fabrcost.DispatchNo      = input.DispatchNo;
                fabrcost.DispReqId       = input.DispatchRequirementId;
                fabrcost.DispStructureId = input.DispatchRequirementStructureId;
                fabrcost.Status          = Util.GetDescription(commonEnum.StructureStatus.NEW).ToString();
                fabrcost.StatusInternal  = Util.GetDescription(commonEnum.StructureStatus.NEW).ToString();
                _context.DispFabricationCost.Add(fabrcost);
                _context.DispReqStructure.Update(dispstructid);
                _context.SaveChanges();

                if (input.uploadDocs != null)
                {
                    foreach (IFormFile file in input.uploadDocs)
                    {
                        Upload_Docs layerDoc = new Upload_Docs();
                        layerDoc.fileName   = file.FileName;
                        layerDoc.filepath   = UploadedFile(file);
                        layerDoc.uploadType = "Docs";
                        layerDoc.fileType   = Path.GetExtension(file.FileName);
                        this._repository.StructureDocsUpload(layerDoc, input.ProjectStructureId);
                        //  _gridRepo.LayerDocsUpload(layerDoc, layerId);
                    }
                }
                RemoveStructureDocs(input.remove_docs_filename);

                _context.SaveChanges();

                responseMessage.Message = "Structure Cost Updated sucessfully";
                return(responseMessage);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        public ResponseMessage AddComponentCost(ADDComponentCost input)
        {
            try
            {
                ProjectStructure structid =
                    _context.ProjectStructure.Single(w => w.Id == input.ProjStructId);
                structid.FabriacationCost = input.Cost;
                ResponseMessage responseMessage = new ResponseMessage();
                //List<DispStructureComp> struct = _context.DispStructureComp.w
                List <Component>    structureComps = _context.Component.Where(w => w.ProjStructId == input.ProjStructId).ToList();
                decimal             count          = structureComps.Sum(x => x.Weight) ?? 1;
                decimal             x        = input.Cost / count;
                DispFabricationCost fabrcost = new DispFabricationCost();
                fabrcost.DispatchNo     = input.DispatchNo;
                fabrcost.DispReqId      = input.DispatchRequirementId;
                fabrcost.Status         = Util.GetDescription(commonEnum.StructureStatus.NEW).ToString();
                fabrcost.StatusInternal = Util.GetDescription(commonEnum.StructureStatus.NEW).ToString();
                _context.DispFabricationCost.Add(fabrcost);
                _context.ProjectStructure.Update(structid);
                _context.SaveChanges();

                structureComps.ForEach(item =>
                {
                    // DispStructureComp structureComps=_context.DispStructureComp.Single(w=>w.DispStructureId==item.DispStructureCompId);

                    item.FabriacationCost = item.Weight * x;
                    _context.Component.Update(item);
                    _context.SaveChanges();
                });



                responseMessage.Message = "Structure Cost Updated sucessfully";
                return(responseMessage);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }