Exemplo n.º 1
0
        public String DeleteGC(GroupCompanyModel gcmodel)
        {
            Company company = CompanyRepository.Companys.SingleOrDefault(c => c.CompanyId == gcmodel.CompanyId);
            //int deletecostbreakup = Task.Run<int>(async () => await CostBreakupRepository.DeleteCostBreakup(costbreakup.CBID)).Result;
            //int deleteproject = Task.Run<int>(async () => await ProjectRepository.DeleteProject(gcpmodel.ProjectId)).Result;
            //int countprojects = ProjectRepository.Projects.Count(p => p.CompanyId == gcpmodel.CompanyId);
            //if (countcompany == 0)
            //{
            //    int deleteCompany =  Task.Run<int>(async () => await CompanyRepository.DeleteCompany(gcpmodel.CompanyId)).Result;
            //}

            IEnumerable <Project> projects = ProjectRepository.Projects.Where(p => p.CompanyId == company.CompanyId && p.GroupId == company.GroupId);

            foreach (Project project in projects)
            {
                Task.Run(async() => await ProjectRepository.DeleteProject(project.ProjectId));
                CostBreakup costbreakup = CostBreakupRepository.CostBreakups.SingleOrDefault(c => c.ProjectID == project.ProjectId);
                Task.Run(async() => await CostBreakupRepository.DeleteCostBreakup(costbreakup.CBID));
            }
            int deletecompany = Task.Run <int>(async() => await CompanyRepository.DeleteCompany(company.CompanyId)).Result;

            int countgroup = CompanyRepository.Companys.Count(c => c.GroupId == gcmodel.GroupId);

            if (countgroup == 0)
            {
                int deleteGroup = Task.Run <int>(async() => await GroupRepository.DeleteGroup(gcmodel.GroupId)).Result;
            }
            //Project project = ProjectRepository.Projects.FirstOrDefault(p => p.ProjectId == gcpmodel.ProjectId);

            return(deletecompany > 0 ? "Successfully Deleted Group" : "Deletion failed");
        }
Exemplo n.º 2
0
        public async Task <int> AddCostBreakup(CostBreakup CostBreakup)
        {
            db.CostBreakups.Add(CostBreakup);
            int result = await db.SaveChangesAsync();

            return(result);
        }
Exemplo n.º 3
0
        public async Task <string> UpdateCostBreakup(CostBreakup costBreakup)
        {
            decimal     totalcost           = 0;
            CostBreakup existingcostBreakup = CostBreakupRepository.GetCostBreakups().SingleOrDefault(c => c.CBID == costBreakup.CBID);

            if (existingcostBreakup == default(CostBreakup))
            {
                return("CostBreakup doesn't exist");
            }


            Project existingproject = ProjectRepository.Projects.SingleOrDefault(p => p.ProjectId == costBreakup.ProjectID);


            totalcost = costBreakup.LandSiteCost.GetValueOrDefault() + costBreakup.SolarModules.GetValueOrDefault() +
                        costBreakup.ModuleMountStruct.GetValueOrDefault() +
                        costBreakup.PowerCondUnit.GetValueOrDefault() + costBreakup.EvacuationCost.GetValueOrDefault() +
                        costBreakup.Preoperativeexp.GetValueOrDefault() +
                        costBreakup.Contingency.GetValueOrDefault() + costBreakup.IDC.GetValueOrDefault()
                        + costBreakup.FinancingCost.GetValueOrDefault()
                        + costBreakup.Workingcapital.GetValueOrDefault()
                        + costBreakup.Dsra.GetValueOrDefault();

            costBreakup.TotalCost     = totalcost;
            existingproject.TotalCost = totalcost;

            int updatecostBreakup = await CostBreakupRepository.UpdateCostBreakup(costBreakup);

            int updateproject = await ProjectRepository.UpdateProject(existingproject);

            return(updatecostBreakup > 0 ? "Successfully updated CostBreakup" : "Updation failed");
        }
Exemplo n.º 4
0
        public async Task <int> DeleteCostBreakup(int cbid)
        {
            CostBreakup CostBreakup = await FetchbyCostBreakupId(cbid);

            db.CostBreakups.Remove(CostBreakup);
            int result = await db.SaveChangesAsync();

            return(result);
        }
Exemplo n.º 5
0
        public IHttpActionResult UpdateCostBreakup(CostBreakup costbreakup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Not a valid model"));
            }
            string message = Task.Run <string>(async() => await _costbreakup.UpdateCostBreakup(costbreakup)).Result;

            return(Ok(message));
        }
Exemplo n.º 6
0
        public CostBreakup GetCostBreakupbyProjectId(int?id)
        {
            if (id == null)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }
            CostBreakup costbreakup = _costbreakup.GetCostBreakupbyProjectId((int)id);

            return(costbreakup);
        }
Exemplo n.º 7
0
        public async Task <int> UpdateCostBreakup(CostBreakup CostBreakup)
        {
            CostBreakup existingCostBreakup = await FetchbyCostBreakupId(CostBreakup.CBID);

            db.Entry(existingCostBreakup).State = EntityState.Detached;
            db.Entry(CostBreakup).State         = EntityState.Modified;
            int result = await db.SaveChangesAsync();

            return(result);
        }
Exemplo n.º 8
0
        public string DeleteProject(int projectId)
        {
            CostBreakup costbreakup       = CostBreakupRepository.CostBreakups.SingleOrDefault(c => c.ProjectID == projectId);
            int         deletecostbreakup = Task.Run <int>(async() => await CostBreakupRepository.DeleteCostBreakup(costbreakup.CBID)).Result;
            Project     project           = ProjectRepository.Projects.SingleOrDefault(p => p.ProjectId == projectId);

            int deleteproject = Task.Run <int>(async() => await ProjectRepository.DeleteProject(projectId)).Result;

            return(deleteproject > 0 ? "Successfully Deleted Project" : "Deletion failed");
        }
Exemplo n.º 9
0
        public CostBreakup GetCostBreakupbyProjectId(int projectId)
        {
            CostBreakup costbreakup = CostBreakupRepository.GetCostBreakups().SingleOrDefault(p => p.ProjectID == projectId);

            return(costbreakup);
        }
Exemplo n.º 10
0
        public async Task <CostBreakup> FetchbyCostBreakupId(int cbid)
        {
            CostBreakup CostBreakup = await db.CostBreakups.FindAsync(cbid);

            return(CostBreakup);
        }