public async Task <WmsdsResponse <int> > AddChannel(Channel channel) { var wmsdResponse = new WmsdsResponse <int>(); if (channel == null) { wmsdResponse.ResponseCode = EnumStatus.EmptyObject; wmsdResponse.ResponseMessage = "Object is empty."; return(wmsdResponse); } if (channel.DistrictId <= 0 || string.IsNullOrEmpty(channel.DistrictName)) { wmsdResponse.ResponseCode = EnumStatus.ValidationFailed;; wmsdResponse.ResponseMessage = "DistrictId is a required field."; return(wmsdResponse); } if (channel.TehsilId <= 0) { wmsdResponse.ResponseCode = EnumStatus.ValidationFailed;; wmsdResponse.ResponseMessage = "TehsilId is a required field."; return(wmsdResponse); } if (string.IsNullOrEmpty(channel.ChannelName)) { wmsdResponse.ResponseCode = EnumStatus.ValidationFailed;; wmsdResponse.ResponseMessage = "Channel Name is a required field."; return(wmsdResponse); } try { using (var _dbContext = new EntityContext()) { _dbContext.Channels.Add(channel); var response = await _dbContext.SaveChangesAsync(); if (response > 0) { wmsdResponse.ResponseCode = EnumStatus.Success;; wmsdResponse.ResponseMessage = "Channel has been added successfully."; return(wmsdResponse); } else { wmsdResponse.ResponseCode = EnumStatus.Failed;; wmsdResponse.ResponseMessage = "Failed to add channel."; return(wmsdResponse); } } } catch (Exception ex) { wmsdResponse.ResponseCode = EnumStatus.InternalServer; wmsdResponse.ResponseMessage = ex.Message; return(wmsdResponse); } }
public async Task <WmsdsResponse <DistrictWiseWcImprDto> > GetDistrictWiseWcImprStatus() { var wmsdResponse = new WmsdsResponse <DistrictWiseWcImprDto>(); wmsdResponse.DataObject = new DistrictWiseWcImprDto(); try { using (var dbContext = new EntityContext()) { var distWiseData = await(from wc in dbContext.WcIdentifications from wd in dbContext.WcIdentificationDetails where wc.Id == wd.WcIdentificationId group wd by new { wc.DistrictName, wd.ImprovementType } into g select new DistrictWiseWcImprDto { District = g.Key.DistrictName, ImprovementType = g.Key.ImprovementType, Value = g.Count(x => x.WcIdentificationId != 0) }).ToListAsync(); wmsdResponse.ResponseCode = EnumStatus.Success; wmsdResponse.Collections = distWiseData; return(wmsdResponse); } } catch (Exception ex) { wmsdResponse.ResponseCode = EnumStatus.Error; wmsdResponse.ResponseMessage = ex.Message; return(wmsdResponse); } }
public async Task <WmsdsResponse <LengthOfWcDto> > GetLengthOfImprovedWc() { var wmsdResponse = new WmsdsResponse <LengthOfWcDto>(); wmsdResponse.DataObject = new LengthOfWcDto(); try { using (var dbContext = new EntityContext()) { var earthenTotalLen = await dbContext.WcIdentificationDetails.SumAsync(x => x.EarthenLengthM); var linedTotalLen = await dbContext.WcIdentificationDetails.SumAsync(x => x.LiningLengthM); wmsdResponse.ResponseCode = EnumStatus.Success; wmsdResponse.DataObject.Earthen = (int)earthenTotalLen / 1000;//KM //wmsdResponse.DataObject.Earthen = wmsdResponse.DataObject.Earthen / 1000;//"000KM" wmsdResponse.DataObject.Lined = (int)linedTotalLen / 1000;//KM //wmsdResponse.DataObject.Lined = wmsdResponse.DataObject.Lined / 1000;//"000KM" wmsdResponse.DataObject.TotalLength = wmsdResponse.DataObject.Earthen + wmsdResponse.DataObject.Lined; return(wmsdResponse); } } catch (Exception ex) { wmsdResponse.ResponseCode = EnumStatus.Error; wmsdResponse.ResponseMessage = ex.Message; return(wmsdResponse); } }
public async Task <WmsdsResponse <KeyValueDto> > GetWcImprovementStatus() { var wmsdResponse = new WmsdsResponse <KeyValueDto>(); wmsdResponse.DataObject = new KeyValueDto(); try { using (var dbContext = new EntityContext()) { var wcImprovementStatus = await(from wd in dbContext.WcIdentificationDetails group wd by new { wd.ImprovementType } into g select new KeyValueDto { name = g.Key.ImprovementType, y = g.Count(x => x.WcIdentificationId != 0) }).ToListAsync(); wmsdResponse.ResponseCode = EnumStatus.Success; wmsdResponse.Collections = wcImprovementStatus; return(wmsdResponse); } } catch (Exception ex) { wmsdResponse.ResponseCode = EnumStatus.Error; wmsdResponse.ResponseMessage = ex.Message; return(wmsdResponse); } }
public async Task <JsonResult> GetWcListing(WcIdentification model) { IWaterCourseService waterCourseService = new WaterCourseService(); WmsdsResponse <WcIdentification> WcIdentifications = await waterCourseService.GetWcIdentifications(1, model.DistrictId, model.TehsilId, model.ChannelId, 0, null); return(Json(WcIdentifications.Collections, JsonRequestBehavior.AllowGet)); }
public async Task <WmsdsResponse <HeisIdentification> > GetHeisIdentifications(int currentPageIndex = 1, int districtId = 0, int tehsilId = 0, string byName = null, string byCnic = null) { var heisIdentificationOut = new WmsdsResponse <HeisIdentification>(); using (var _dbContext = new EntityContext()) { int maxRows = 20; heisIdentificationOut.Collections = await _dbContext.HeisIdentifications .Where(c => districtId == 0 || c.DistrictId == districtId) .Where(c => tehsilId == 0 || c.TehsilId == tehsilId) .Where(c => byCnic == null || c.FarmerCNIC.Contains(byCnic)) .Where(c => byName == null || c.FarmerName.Contains(byName)) .Include(x => x.HeisIdentificationDetails) .OrderBy(x => x.Id) .Skip((currentPageIndex - 1) * maxRows) .Take(maxRows).ToListAsync(); int rowCount = await _dbContext.HeisIdentifications .Where(c => districtId == 0 || c.DistrictId == districtId) .Where(c => tehsilId == 0 || c.TehsilId == tehsilId) .Where(c => byCnic == null || c.FarmerCNIC.Contains(byCnic)) .Where(c => byName == null || c.FarmerName.Contains(byName)) .CountAsync(); heisIdentificationOut.TotalRecords = rowCount; double pageCount = (double)((decimal)rowCount / Convert.ToDecimal(maxRows)); heisIdentificationOut.PageCount = (int)Math.Ceiling(pageCount); heisIdentificationOut.CurrentPageIndex = currentPageIndex; return(heisIdentificationOut); } }
public async Task <WmsdsResponse <WatercoureseStatusDto> > GetStatusOfWatercourses() { var wmsdResponse = new WmsdsResponse <WatercoureseStatusDto>(); wmsdResponse.DataObject = new WatercoureseStatusDto(); try { using (var dbContext = new EntityContext()) { var improvedWcCount = await(from wc in dbContext.WcIdentifications from wd in dbContext.WcIdentificationDetails where wc.Id == wd.WcIdentificationId select wc.Id).CountAsync(); var totalWcCourse = await dbContext.WaterCourses.CountAsync(); wmsdResponse.DataObject.TotalWaterCourse = totalWcCourse; wmsdResponse.DataObject.ImprovedWaterCourse = improvedWcCount; wmsdResponse.DataObject.UnImprovedWaterCourse = totalWcCourse - improvedWcCount; wmsdResponse.ResponseCode = EnumStatus.Success; wmsdResponse.ResponseMessage = "Success"; return(wmsdResponse); } } catch (Exception ex) { wmsdResponse.ResponseCode = EnumStatus.Error; wmsdResponse.ResponseMessage = ex.Message; return(wmsdResponse); } }
public async Task <WmsdsResponse <ImplicationFinancialDto> > GetImplicationFinancial() { var wmsdResponse = new WmsdsResponse <ImplicationFinancialDto>(); wmsdResponse.DataObject = new ImplicationFinancialDto(); try { using (var dbContext = new EntityContext()) { //TODO: discuss about farmer share var totalGovtShare = await dbContext.WcIdentificationDetails.SumAsync(x => x.TotalCostOfCivilWrkVerfied);//Govt var linedTotalLen = await dbContext.WcIdentificationDetails.SumAsync(x => x.LiningLengthM); wmsdResponse.ResponseCode = EnumStatus.Success; //wmsdResponse.DataObject.GovtAssistance = (int)earthenTotalLen / 1000;//KM //wmsdResponse.DataObject.Earthen = wmsdResponse.DataObject.Earthen / 1000;//"000KM" //wmsdResponse.DataObject.Lined = (int)linedTotalLen / 1000;//KM //wmsdResponse.DataObject.Lined = wmsdResponse.DataObject.Lined / 1000;//"000KM" //wmsdResponse.DataObject.TotalLength = wmsdResponse.DataObject.Earthen + wmsdResponse.DataObject.Lined; return(wmsdResponse); } } catch (Exception ex) { wmsdResponse.ResponseCode = EnumStatus.Error; wmsdResponse.ResponseMessage = ex.Message; return(wmsdResponse); } }
public async Task <WmsdsResponse <int> > AddHeisIdentification(HeisIdentification heisIdentification) { var wmsdResponse = new WmsdsResponse <int>(); if (heisIdentification == null) { wmsdResponse.ResponseCode = EnumStatus.EmptyObject; wmsdResponse.ResponseMessage = "Object is empty."; return(wmsdResponse); } if (heisIdentification.DistrictId <= 0 || string.IsNullOrEmpty(heisIdentification.DistrictName)) { wmsdResponse.ResponseCode = EnumStatus.ValidationFailed;; wmsdResponse.ResponseMessage = "DistrictId is a required field."; return(wmsdResponse); } if (heisIdentification.TehsilId <= 0 || string.IsNullOrEmpty(heisIdentification.TehsilName)) { wmsdResponse.ResponseCode = EnumStatus.ValidationFailed;; wmsdResponse.ResponseMessage = "TehsilId is a required field."; return(wmsdResponse); } if (await IsHeisIdentificationAlreadyExist(heisIdentification)) { wmsdResponse.ResponseCode = EnumStatus.AlreadyExist; wmsdResponse.ResponseMessage = "Watercourse already exists."; return(wmsdResponse); } //Check if status is Addation than there must be a regular water course try { using (var _dbContext = new EntityContext()) { _dbContext.HeisIdentifications.Add(heisIdentification); var response = await _dbContext.SaveChangesAsync(); if (response > 0) { wmsdResponse.ResponseCode = EnumStatus.Success;; wmsdResponse.ResponseMessage = "Identicification has been added successfully."; return(wmsdResponse); } else { wmsdResponse.ResponseCode = EnumStatus.Failed;; wmsdResponse.ResponseMessage = "Failed to add channel."; return(wmsdResponse); } } } catch (Exception ex) { wmsdResponse.ResponseCode = EnumStatus.InternalServer; wmsdResponse.ResponseMessage = ex.Message; return(wmsdResponse); } }
/// <summary> /// Get List of Identifications /// </summary> /// <param name="districtId"></param> /// <param name="tehsilId"></param> /// <param name="channelId"></param> /// <param name="improveYearId"></param> /// <returns></returns> public async Task <WmsdsResponse <WcIdentification> > GetWcIdentifications(int currentPageIndex = 1, int districtId = 0, int tehsilId = 0, int channelId = 0, int improveYearId = 0, string improvementType = null) { var wcIdentificationOut = new WmsdsResponse <WcIdentification>(); using (var _dbContext = new EntityContext()) { try { //var wcIdentifications = await (from ep in _dbContext.WcIdentifications // join d in _dbContext.WcIdentificationDetails on ep.Id equals d.WcIdentificationId // where // (ep.DistrictId == 0 || ep.DistrictId == districtId) && (ep.TehsilId == 0 || ep.TehsilId == tehsilId) // && (d.ImprovementYearId == 0 || d.ImprovementYearId == tehsilId) // && (d.ImprovementType == null || d.ImprovementType == improvementType) // select new WcIdentification // { // Id = ep.Id, // DivisionName = ep.DivisionName, // DistrictName = ep.DistrictName, // TehsilName = ep.TehsilName // }).ToListAsync(); int maxRows = 20; wcIdentificationOut.Collections = await _dbContext.WcIdentifications .Where(c => districtId == 0 || c.DistrictId == districtId) .Where(c => tehsilId == 0 || c.TehsilId == tehsilId) .Where(c => channelId == 0 || c.ChannelId == channelId) .Include(x => x.WcIdentificationDetails) .OrderBy(x => x.Id) .Skip((currentPageIndex - 1) * maxRows) .Take(maxRows).ToListAsync(); int rowCount = await _dbContext.WcIdentifications .Where(c => districtId == 0 || c.DistrictId == districtId) .Where(c => tehsilId == 0 || c.TehsilId == tehsilId) .Where(c => channelId == 0 || c.ChannelId == channelId).CountAsync(); wcIdentificationOut.TotalRecords = rowCount; double pageCount = (double)((decimal)rowCount / Convert.ToDecimal(maxRows)); wcIdentificationOut.PageCount = (int)Math.Ceiling(pageCount); wcIdentificationOut.CurrentPageIndex = currentPageIndex; return(wcIdentificationOut); } catch (Exception ex) { return(null); } //.Where(c => improveYearId == 0 || c.ImprovementYearId == improveYearId) } }
public async Task <WmsdsResponse <HeisIdentificationDetail> > AddHeisBasicInformation(HeisIdentificationDetail heisIdentificationDetail) { var wmsdResponse = new WmsdsResponse <HeisIdentificationDetail>(); if (heisIdentificationDetail == null) { wmsdResponse.ResponseCode = EnumStatus.EmptyObject; wmsdResponse.ResponseMessage = "Object is empty."; return(wmsdResponse); } if (heisIdentificationDetail.HeisIdentificationId <= 0) { wmsdResponse.ResponseCode = EnumStatus.EmptyObject; wmsdResponse.ResponseMessage = "HEIS Parent Identification key is empty."; return(wmsdResponse); } try { using (var _dbContext = new EntityContext()) { _dbContext.HeisIdentificationDetails.Add(heisIdentificationDetail); var response = await _dbContext.SaveChangesAsync(); if (response > 0) { wmsdResponse.ResponseCode = EnumStatus.Success; wmsdResponse.DataObject = new HeisIdentificationDetail(); wmsdResponse.DataObject.Id = heisIdentificationDetail.Id; wmsdResponse.ResponseMessage = "Record has been added successfully."; return(wmsdResponse); } else { wmsdResponse.ResponseCode = EnumStatus.Failed;; wmsdResponse.ResponseMessage = "Failed to update record."; return(wmsdResponse); } } } catch (Exception ex) { wmsdResponse.ResponseCode = EnumStatus.InternalServer; wmsdResponse.ResponseMessage = ex.Message; return(wmsdResponse); } }
public async Task <WmsdsResponse <WcIdentificationDetail> > GetIdentificationDetailByMasterId(int wcIdentificationId) { var wmsdResponse = new WmsdsResponse <WcIdentificationDetail>(); if (wcIdentificationId <= 0) { wmsdResponse.ResponseCode = EnumStatus.RequiredField; wmsdResponse.ResponseMessage = "Water Course Id is missing."; return(wmsdResponse); } using (var _dbContext = new EntityContext()) { try { var wcIdentification = await _dbContext.WcIdentificationDetails .Where(c => c.WcIdentificationId == wcIdentificationId) .FirstOrDefaultAsync(); if (wcIdentification != null) { wmsdResponse.ResponseCode = EnumStatus.Success; wmsdResponse.DataObject = wcIdentification; wmsdResponse.ResponseMessage = "Record Found."; return(wmsdResponse); } else { wmsdResponse.ResponseCode = EnumStatus.NotFound; wmsdResponse.ResponseMessage = "No Record Found."; return(wmsdResponse); } } catch (Exception ex) { wmsdResponse.ResponseCode = EnumStatus.InternalServer; wmsdResponse.ResponseMessage = ex.Message; return(wmsdResponse); } } }
public async Task <WmsdsResponse <HeisIdentification> > GetHeisIdentificationById(int heisIdentificationId) { var wmsdResponse = new WmsdsResponse <HeisIdentification>(); if (heisIdentificationId <= 0) { wmsdResponse.ResponseCode = EnumStatus.RequiredField; wmsdResponse.ResponseMessage = "HEIS Identification Id is missing."; return(wmsdResponse); } using (var _dbContext = new EntityContext()) { try { var wcIdentification = await _dbContext.HeisIdentifications .Where(c => c.Id == heisIdentificationId) .SingleOrDefaultAsync(); if (wcIdentification != null) { wmsdResponse.ResponseCode = EnumStatus.Success; wmsdResponse.DataObject = wcIdentification; wmsdResponse.ResponseMessage = "Record Found."; return(wmsdResponse); } else { wmsdResponse.ResponseCode = EnumStatus.NotFound; wmsdResponse.ResponseMessage = "No Record Found."; return(wmsdResponse); } } catch (Exception ex) { wmsdResponse.ResponseCode = EnumStatus.InternalServer; wmsdResponse.ResponseMessage = ex.Message; return(wmsdResponse); } } }
public async Task <ActionResult> AddUpdateHEISDetails(FormCollection formCollection) { try { int HeisIdentificationId = Convert.ToInt16(formCollection["hdHeisIdentificationIdBI"]); int HeisIdentificationDetailId = Convert.ToInt16(formCollection["hdHeisIdentificationDetailsIdBI"]); double Latitude = Convert.ToDouble(formCollection["txtLatitude"]); double Longitude = Convert.ToDouble(formCollection["txtLongitude"]); string InstallationType = formCollection["ddlInstallationType"] + "".Replace("--Select--", ""); string FiscalYear = formCollection["ddlFiscalYear"] + "".Replace("--Select--", ""); string SystemType = formCollection["ddlSystemType"] + "".Replace("--Select--", ""); string SSCName = formCollection["ddlSSCName"] + "".Replace("--Select--", ""); string ProjectName = formCollection["ddlProjectName"] + "".Replace("--Select--", ""); string VillageName = formCollection["txtVillageName"]; string ContactNumber = formCollection["txtContactNumber"]; int SchemeArea = Convert.ToInt16(formCollection["txtSchemeArea"]); string WaterSource = formCollection["ddlWaterSource"] + "".Replace("--Select--", ""); string WaterQuality = formCollection["ddlWaterQuality"] + "".Replace("--Select--", ""); string PowerSource = formCollection["ddlPowerSource"] + "".Replace("--Select--", ""); string CropCategory = formCollection["ddlCropCategory"] + "".Replace("--Select--", ""); string CropName = formCollection["ddlCropName"] + "".Replace("--Select--", ""); int PlansPerAcre = Convert.ToInt16(formCollection["txtPlansPerAcre"]); string SystemClassification = formCollection["ddlSystemClassification"] + "".Replace("--Select--", ""); string WorkOrderIssued = formCollection["ddlWorkOrderIssued"] + "".Replace("--Select--", ""); DateTime DesignApprovalDate = DateTime.ParseExact(formCollection["txtDesignApprovalDate"].ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture); int TotalApprovedProjectCost = Convert.ToInt16(formCollection["txtTotalApprovedProjectCost"]); int TotalDynamicHead = Convert.ToInt16(formCollection["txtTotalDynamicHead"]); string PumpType = formCollection["ddlPumpType"] + "".Replace("--Select--", ""); int PumpFlowRate = Convert.ToInt16(formCollection["txtPumpFlowRate"]); int PowerSourceEfficiency = Convert.ToInt16(formCollection["txtPowerSourceEfficiency"]); HeisIdentificationDetail heisIdentificationDetail = new HeisIdentificationDetail(); heisIdentificationDetail.HeisIdentificationId = HeisIdentificationId; heisIdentificationDetail.Id = HeisIdentificationDetailId; heisIdentificationDetail.Latitude = Latitude; heisIdentificationDetail.Longitude = Longitude; heisIdentificationDetail.InstallationType = InstallationType; heisIdentificationDetail.FiscalYear = FiscalYear; heisIdentificationDetail.SystemType = SystemType; heisIdentificationDetail.SSCName = SSCName; heisIdentificationDetail.ProjectName = ProjectName; heisIdentificationDetail.VillageName = VillageName; heisIdentificationDetail.ContactNumber = ContactNumber; heisIdentificationDetail.SchemeArea = SchemeArea; heisIdentificationDetail.WaterSource = WaterSource; heisIdentificationDetail.WaterQuality = WaterQuality; heisIdentificationDetail.PowerSource = PowerSource; heisIdentificationDetail.CropCategory = CropCategory; heisIdentificationDetail.CropName = CropName; heisIdentificationDetail.PlansPerAcre = PlansPerAcre; heisIdentificationDetail.SystemClassification = SystemClassification; heisIdentificationDetail.WorkOrderIssued = WorkOrderIssued; heisIdentificationDetail.DesignApprovalDate = DesignApprovalDate; heisIdentificationDetail.TotalApprovedProjectCost = TotalApprovedProjectCost; heisIdentificationDetail.TotalDynamicHead = TotalDynamicHead; heisIdentificationDetail.PumpType = PumpType; heisIdentificationDetail.PumpFlowRate = PumpFlowRate; heisIdentificationDetail.PowerSourceEfficiency = PowerSourceEfficiency; IHeisService heisCourseService = new HeisService(); var response = new WmsdsResponse <HeisIdentificationDetail>(); var responseUpdate = new WmsdsResponse <int>(); if (HeisIdentificationDetailId == 0) { response = await heisCourseService.AddHeisBasicInformation(heisIdentificationDetail); return(Json(response, JsonRequestBehavior.AllowGet)); } else { responseUpdate = await heisCourseService.UpdateHeisBasicInformation(heisIdentificationDetail); return(Json(responseUpdate, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { FormId = 0, HttpStatusCode = HttpStatusCode.NotImplemented })); } }
public async Task <WmsdsResponse <int> > UpdateHeisBasicInformation(HeisIdentificationDetail heisIdentificationDetail) { var wmsdResponse = new WmsdsResponse <int>(); if (heisIdentificationDetail == null) { wmsdResponse.ResponseCode = EnumStatus.EmptyObject; wmsdResponse.ResponseMessage = "Object is empty."; return(wmsdResponse); } if (heisIdentificationDetail.HeisIdentificationId <= 0) { wmsdResponse.ResponseCode = EnumStatus.EmptyObject; wmsdResponse.ResponseMessage = "Parent Identification key is empty."; return(wmsdResponse); } if (heisIdentificationDetail.Id <= 0) { wmsdResponse.ResponseCode = EnumStatus.EmptyObject; wmsdResponse.ResponseMessage = "Id is missing."; return(wmsdResponse); } try { using (var _dbContext = new EntityContext()) { var basicInfoDb = await _dbContext.HeisIdentificationDetails .Where(c => c.Id == heisIdentificationDetail.Id && c.HeisIdentificationId == heisIdentificationDetail.HeisIdentificationId) .SingleOrDefaultAsync(); if (basicInfoDb != null) { basicInfoDb.InstallationType = string.IsNullOrEmpty(heisIdentificationDetail.InstallationType) ? basicInfoDb.InstallationType : heisIdentificationDetail.InstallationType; basicInfoDb.FiscalYear = string.IsNullOrEmpty(heisIdentificationDetail.FiscalYear) ? basicInfoDb.FiscalYear : heisIdentificationDetail.FiscalYear; basicInfoDb.FiscalYearId = heisIdentificationDetail.FiscalYearId <= 0 ? basicInfoDb.FiscalYearId : heisIdentificationDetail.FiscalYearId; basicInfoDb.SystemType = string.IsNullOrEmpty(heisIdentificationDetail.SystemType) ? basicInfoDb.SystemType : heisIdentificationDetail.SystemType; basicInfoDb.SSCName = string.IsNullOrEmpty(heisIdentificationDetail.SSCName) ? basicInfoDb.SSCName : heisIdentificationDetail.SSCName; basicInfoDb.SSCId = heisIdentificationDetail.SSCId <= 0 ? basicInfoDb.SSCId : heisIdentificationDetail.SSCId; basicInfoDb.ProjectName = string.IsNullOrEmpty(heisIdentificationDetail.ProjectName) ? basicInfoDb.ProjectName : heisIdentificationDetail.ProjectName; basicInfoDb.VillageName = string.IsNullOrEmpty(heisIdentificationDetail.VillageName) ? basicInfoDb.VillageName : heisIdentificationDetail.VillageName; basicInfoDb.ContactNumber = string.IsNullOrEmpty(heisIdentificationDetail.ContactNumber) ? basicInfoDb.ContactNumber : heisIdentificationDetail.ContactNumber; basicInfoDb.SoilType = string.IsNullOrEmpty(heisIdentificationDetail.SoilType) ? basicInfoDb.SoilType : heisIdentificationDetail.SoilType; basicInfoDb.SchemeArea = heisIdentificationDetail.SchemeArea <= 0 ? basicInfoDb.SchemeArea : heisIdentificationDetail.SchemeArea; basicInfoDb.WaterSource = string.IsNullOrEmpty(heisIdentificationDetail.WaterSource) ? basicInfoDb.WaterSource : heisIdentificationDetail.WaterSource; basicInfoDb.WaterQuality = string.IsNullOrEmpty(heisIdentificationDetail.WaterQuality) ? basicInfoDb.WaterQuality : heisIdentificationDetail.WaterQuality; basicInfoDb.PowerSource = string.IsNullOrEmpty(heisIdentificationDetail.PowerSource) ? basicInfoDb.PowerSource : heisIdentificationDetail.PowerSource; basicInfoDb.CropCategory = string.IsNullOrEmpty(heisIdentificationDetail.CropCategory) ? basicInfoDb.CropCategory : heisIdentificationDetail.CropCategory; basicInfoDb.CropName = string.IsNullOrEmpty(heisIdentificationDetail.CropName) ? basicInfoDb.CropName : heisIdentificationDetail.CropName; basicInfoDb.PlansPerAcre = heisIdentificationDetail.PlansPerAcre <= 0 ? basicInfoDb.PlansPerAcre : heisIdentificationDetail.PlansPerAcre; basicInfoDb.SystemClassification = string.IsNullOrEmpty(heisIdentificationDetail.SystemClassification) ? basicInfoDb.SystemClassification : heisIdentificationDetail.SystemClassification; basicInfoDb.Latitude = heisIdentificationDetail.Latitude <= 0 ? basicInfoDb.Latitude : heisIdentificationDetail.Latitude; basicInfoDb.Longitude = heisIdentificationDetail.Longitude <= 0 ? basicInfoDb.Longitude : heisIdentificationDetail.Longitude; var response = await _dbContext.SaveChangesAsync(); if (response > 0) { wmsdResponse.ResponseCode = EnumStatus.Success;; wmsdResponse.ResponseMessage = "Record has been added successfully."; return(wmsdResponse); } else { wmsdResponse.ResponseCode = EnumStatus.Failed;; wmsdResponse.ResponseMessage = "Failed to update record."; return(wmsdResponse); } } else { wmsdResponse.ResponseCode = EnumStatus.NotFound;; wmsdResponse.ResponseMessage = "No Record found against given Ids."; return(wmsdResponse); } } } catch (Exception ex) { wmsdResponse.ResponseCode = EnumStatus.InternalServer; wmsdResponse.ResponseMessage = ex.Message; return(wmsdResponse); } }
/// <summary> /// AddWorksExecuted will add/update below sections /// i-Design Parameters /// ii-Work Order /// iii-Material Verification (ICR-I) /// iv-Commissioning Verification (ICR-II) /// v-Third Installment (ICR-III) /// </summary> /// <param name="heisIdentificationDetail"></param> /// <returns></returns> public async Task <WmsdsResponse <int> > AddWorksExecuted(HeisIdentificationDetail heisIdentificationDetail) { var wmsdResponse = new WmsdsResponse <int>(); if (heisIdentificationDetail == null) { wmsdResponse.ResponseCode = EnumStatus.EmptyObject; wmsdResponse.ResponseMessage = "Object is empty."; return(wmsdResponse); } if (heisIdentificationDetail.HeisIdentificationId <= 0) { wmsdResponse.ResponseCode = EnumStatus.EmptyObject; wmsdResponse.ResponseMessage = "Parent Identification key is empty."; return(wmsdResponse); } if (heisIdentificationDetail.Id <= 0) { wmsdResponse.ResponseCode = EnumStatus.EmptyObject; wmsdResponse.ResponseMessage = "Id is missing."; return(wmsdResponse); } try { using (var _dbContext = new EntityContext()) { var basicInfoDb = await _dbContext.HeisIdentificationDetails .Where(c => c.Id == heisIdentificationDetail.Id && c.HeisIdentificationId == heisIdentificationDetail.HeisIdentificationId) .SingleOrDefaultAsync(); if (basicInfoDb != null) { #region Design Parameters basicInfoDb.DesignApproved = string.IsNullOrEmpty(heisIdentificationDetail.DesignApproved) ? basicInfoDb.DesignApproved : heisIdentificationDetail.DesignApproved; basicInfoDb.DesignApprovalDate = basicInfoDb.DesignApprovalDate == null ? basicInfoDb.DesignApprovalDate : heisIdentificationDetail.DesignApprovalDate; basicInfoDb.TotalApprovedProjectCost = heisIdentificationDetail.TotalApprovedProjectCost <= 0 ? basicInfoDb.TotalApprovedProjectCost : heisIdentificationDetail.TotalApprovedProjectCost; basicInfoDb.TotalDynamicHead = heisIdentificationDetail.TotalDynamicHead <= 0 ? basicInfoDb.TotalDynamicHead : heisIdentificationDetail.TotalDynamicHead; basicInfoDb.PumpType = string.IsNullOrEmpty(heisIdentificationDetail.PumpType) ? basicInfoDb.PumpType : heisIdentificationDetail.PumpType; basicInfoDb.PumpFlowRate = heisIdentificationDetail.PumpFlowRate <= 0 ? basicInfoDb.PumpFlowRate : heisIdentificationDetail.PumpFlowRate; basicInfoDb.PowerSourceEfficiency = heisIdentificationDetail.PowerSourceEfficiency <= 0 ? basicInfoDb.PowerSourceEfficiency : heisIdentificationDetail.PowerSourceEfficiency; #endregion #region Work Order basicInfoDb.WorkOrderIssued = string.IsNullOrEmpty(heisIdentificationDetail.WorkOrderIssued) ? basicInfoDb.WorkOrderIssued : heisIdentificationDetail.WorkOrderIssued; basicInfoDb.WorkOrderIssueDate = basicInfoDb.WorkOrderIssueDate == null ? basicInfoDb.WorkOrderIssueDate : heisIdentificationDetail.WorkOrderIssueDate; basicInfoDb.WorkOrderAmount = heisIdentificationDetail.WorkOrderAmount <= 0 ? basicInfoDb.WorkOrderAmount : heisIdentificationDetail.WorkOrderAmount; basicInfoDb.EstimatedGovtShare = heisIdentificationDetail.EstimatedGovtShare <= 0 ? basicInfoDb.EstimatedGovtShare : heisIdentificationDetail.EstimatedGovtShare; basicInfoDb.EstimatedFamerShare = heisIdentificationDetail.EstimatedFamerShare <= 0 ? basicInfoDb.EstimatedFamerShare : heisIdentificationDetail.EstimatedFamerShare; basicInfoDb.FarmerShareInCash = heisIdentificationDetail.FarmerShareInCash <= 0 ? basicInfoDb.FarmerShareInCash : heisIdentificationDetail.FarmerShareInCash; basicInfoDb.FarmerShareInKind = heisIdentificationDetail.FarmerShareInKind <= 0 ? basicInfoDb.FarmerShareInKind : heisIdentificationDetail.FarmerShareInKind; #endregion #region Material Verification (ICR-I) basicInfoDb.MaterialVerified = string.IsNullOrEmpty(heisIdentificationDetail.MaterialVerified) ? basicInfoDb.MaterialVerified : heisIdentificationDetail.MaterialVerified; basicInfoDb.MaterialVerifiedDate = basicInfoDb.MaterialVerifiedDate == null ? basicInfoDb.MaterialVerifiedDate : heisIdentificationDetail.MaterialVerifiedDate; basicInfoDb.ICRIAmountVerified = heisIdentificationDetail.ICRIAmountVerified <= 0 ? basicInfoDb.ICRIAmountVerified : heisIdentificationDetail.ICRIAmountVerified; #endregion #region Commissioning Verification (ICR-II) basicInfoDb.CommissioningVerification = string.IsNullOrEmpty(heisIdentificationDetail.CommissioningVerification) ? basicInfoDb.CommissioningVerification : heisIdentificationDetail.CommissioningVerification; basicInfoDb.CommissioningVerificationDate = basicInfoDb.CommissioningVerificationDate == null ? basicInfoDb.CommissioningVerificationDate : heisIdentificationDetail.CommissioningVerificationDate; basicInfoDb.TotalSchemeCostVerified = heisIdentificationDetail.TotalSchemeCostVerified <= 0 ? basicInfoDb.TotalSchemeCostVerified : heisIdentificationDetail.TotalSchemeCostVerified; basicInfoDb.ICRIIAmountVerified = heisIdentificationDetail.ICRIIAmountVerified <= 0 ? basicInfoDb.ICRIIAmountVerified : heisIdentificationDetail.ICRIIAmountVerified; #endregion #region Third Installment (ICR-III) basicInfoDb.ICRIIIVerification = string.IsNullOrEmpty(heisIdentificationDetail.ICRIIIVerification) ? basicInfoDb.ICRIIIVerification : heisIdentificationDetail.ICRIIIVerification; basicInfoDb.TotalAmountVerified = heisIdentificationDetail.TotalAmountVerified <= 0 ? basicInfoDb.TotalAmountVerified : heisIdentificationDetail.TotalAmountVerified; basicInfoDb.ICRIIIQualifyingDate = basicInfoDb.ICRIIIQualifyingDate == null ? basicInfoDb.ICRIIIQualifyingDate : heisIdentificationDetail.ICRIIIQualifyingDate; #endregion var response = await _dbContext.SaveChangesAsync(); if (response > 0) { wmsdResponse.ResponseCode = EnumStatus.Success;; wmsdResponse.ResponseMessage = "Record has been added successfully."; return(wmsdResponse); } else { wmsdResponse.ResponseCode = EnumStatus.Failed;; wmsdResponse.ResponseMessage = "Failed to update record."; return(wmsdResponse); } } else { wmsdResponse.ResponseCode = EnumStatus.NotFound;; wmsdResponse.ResponseMessage = "No Record found against given Ids."; return(wmsdResponse); } } } catch (Exception ex) { wmsdResponse.ResponseCode = EnumStatus.InternalServer; wmsdResponse.ResponseMessage = ex.Message; return(wmsdResponse); } }
public async Task <JsonResult> AjaxMethod(int pageIndex, string sortName, string sortDirection) { IWaterCourseService waterCourseService = new WaterCourseService(); WmsdsResponse <WcIdentification> model = new WmsdsResponse <WcIdentification>(); model.PageIndex = pageIndex; model.PageSize = 10; var wmsdsResponse = await waterCourseService.GetWcIdentifications(pageIndex, 0, 0, 0, 0, null); model.Collections = wmsdsResponse.Collections; model.RecordCount = wmsdsResponse.TotalRecords; int startIndex = (pageIndex - 1) * model.PageSize; //switch (sortName) //{ // case "CustomerID": // case "": // if (sortDirection == "ASC") // { // model.Customers = (from customer in entities.Customers // select customer) // .OrderBy(customer => customer.CustomerID) // .Skip(startIndex) // .Take(model.PageSize).ToList(); // } // else // { // model.Customers = (from customer in entities.Customers // select customer) // .OrderByDescending(customer => customer.CustomerID) // .Skip(startIndex) // .Take(model.PageSize).ToList(); // } // break; // case "ContactName": // if (sortDirection == "ASC") // { // model.Customers = (from customer in entities.Customers // select customer) // .OrderBy(customer => customer.ContactName) // .Skip(startIndex) // .Take(model.PageSize).ToList(); // } // else // { // model.Customers = (from customer in entities.Customers // select customer) // .OrderByDescending(customer => customer.ContactName) // .Skip(startIndex) // .Take(model.PageSize).ToList(); // } // break; // case "City": // if (sortDirection == "ASC") // { // model.Customers = (from customer in entities.Customers // select customer) // .OrderBy(customer => customer.City) // .Skip(startIndex) // .Take(model.PageSize).ToList(); // } // else // { // model.Customers = (from customer in entities.Customers // select customer) // .OrderByDescending(customer => customer.City) // .Skip(startIndex) // .Take(model.PageSize).ToList(); // } // break; // case "Country": // if (sortDirection == "ASC") // { // model.Customers = (from customer in entities.Customers // select customer) // .OrderBy(customer => customer.Country) // .Skip(startIndex) // .Take(model.PageSize).ToList(); // } // else // { // model.Customers = (from customer in entities.Customers // select customer) // .OrderByDescending(customer => customer.Country) // .Skip(startIndex) // .Take(model.PageSize).ToList(); // } // break; //} return(Json(model)); }
public async Task <ActionResult> AddUpdateWatercourseDetails(FormCollection formCollection) { try { int WcIdentificationId = Convert.ToInt16(formCollection["hdWcIdentificationIdBI"]); int WcIdentificationDetailId = Convert.ToInt16(formCollection["hdWcIdentificationDetailsIdBI"]); int ImprovementYearId = Convert.ToInt16(formCollection["ddlImprovementYear"]); string ImprovementType = formCollection["ddlImprovementType"] + ""; double Latitude = Convert.ToDouble(formCollection["txtLatitude"]); double Longitude = Convert.ToDouble(formCollection["txtLongitude"]); string ProjectName = formCollection["ddlProjectName"] + "".Replace("--Select--", ""); string VillageName = formCollection["txtVillageName"] + ""; string UC = formCollection["txtUC"] + ""; decimal GCA = Convert.ToDecimal(formCollection["txtGCA"]); decimal CCA = Convert.ToDecimal(formCollection["txtCCA"]); decimal SanctionedDischarge = Convert.ToDecimal(formCollection["txtSanctionedDischarge"]); decimal DesignDischarge = Convert.ToDecimal(formCollection["txtDesignDischarge"]); string MoghaType = formCollection["ddlMoghaType"] + "".Replace("--Select--", ""); string GroundwaterQuality = formCollection["ddlGroundwaterQuality"] + "".Replace("--Select--", ""); string NameOfWUAChairman = formCollection["txtNameOfWUAChairman"] + ""; string ContactOfWUAChairman = formCollection["txtContactOfWUAChairman"] + ""; int NoOfBeneficiaries = Convert.ToInt16(formCollection["txtNoOfBeneficiaries"]); decimal TotalLength = Convert.ToDecimal(formCollection["txtTotalLength"]); WcIdentificationDetail wcIdentificationDetail = new WcIdentificationDetail(); wcIdentificationDetail.WcIdentificationId = WcIdentificationId; wcIdentificationDetail.Id = WcIdentificationDetailId; wcIdentificationDetail.Latitude = Latitude; wcIdentificationDetail.Longitude = Longitude; wcIdentificationDetail.ProjectName = ProjectName; wcIdentificationDetail.VillageName = VillageName; wcIdentificationDetail.UC = UC; wcIdentificationDetail.GCA = GCA; wcIdentificationDetail.CCA = CCA; wcIdentificationDetail.SanctionedDischargeLPS = SanctionedDischarge; wcIdentificationDetail.DesignDischargeLPS = DesignDischarge; wcIdentificationDetail.MoghaType = MoghaType; wcIdentificationDetail.GroundwaterQuality = GroundwaterQuality; wcIdentificationDetail.WUAChairman = NameOfWUAChairman; wcIdentificationDetail.ChairmanContactNo = ContactOfWUAChairman; wcIdentificationDetail.TotalLengthM = TotalLength; wcIdentificationDetail.ImprovementYearId = ImprovementYearId; wcIdentificationDetail.ImprovementType = ImprovementType; IWaterCourseService waterCourseService = new WaterCourseService(); var response = new WmsdsResponse <WcIdentificationDetail>(); var responseUpdate = new WmsdsResponse <int>(); if (WcIdentificationDetailId == 0) { response = await waterCourseService.AddBasicInformation(wcIdentificationDetail); return(Json(response, JsonRequestBehavior.AllowGet)); } else { responseUpdate = await waterCourseService.UpdateBasicInformation(wcIdentificationDetail); return(Json(responseUpdate, JsonRequestBehavior.AllowGet)); } } catch (Exception) { return(Json(new { FormId = 0, HttpStatusCode = HttpStatusCode.NotImplemented })); } }
/// <summary> /// Add Identification of a water course /// </summary> /// <param name="wcIdentification"></param> /// <returns></returns> public async Task <WmsdsResponse <int> > AddIdentification(WcIdentification wcIdentification) { var wmsdResponse = new WmsdsResponse <int>(); if (wcIdentification == null) { wmsdResponse.ResponseCode = EnumStatus.EmptyObject; wmsdResponse.ResponseMessage = "Object is empty."; return(wmsdResponse); } if (wcIdentification.DistrictId <= 0 || string.IsNullOrEmpty(wcIdentification.DistrictName)) { wmsdResponse.ResponseCode = EnumStatus.ValidationFailed;; wmsdResponse.ResponseMessage = "DistrictId is a required field."; return(wmsdResponse); } if (wcIdentification.TehsilId <= 0 || string.IsNullOrEmpty(wcIdentification.TehsilName)) { wmsdResponse.ResponseCode = EnumStatus.ValidationFailed;; wmsdResponse.ResponseMessage = "TehsilId is a required field."; return(wmsdResponse); } if (wcIdentification.ChannelId <= 0 || string.IsNullOrEmpty(wcIdentification.ChannelName)) { wmsdResponse.ResponseCode = EnumStatus.ValidationFailed;; wmsdResponse.ResponseMessage = "Channel Name is a required field."; return(wmsdResponse); } if (wcIdentification.WaterCourseId <= 0 || string.IsNullOrEmpty(wcIdentification.WaterCourseNo)) { wmsdResponse.ResponseCode = EnumStatus.ValidationFailed;; wmsdResponse.ResponseMessage = "WaterCourse No is a required field."; return(wmsdResponse); } //Check If WcIdentification Already Exists with Regular Status //if (wcIdentification.ImprovementType == EnumWcImprovementType.Regular.ToString() && await IsWcIdentificationAlreadyExist(wcIdentification)) //{ // wmsdResponse.ResponseCode = EnumStatus.AlreadyExist; // wmsdResponse.ResponseMessage = "Watercourse already exists."; // return wmsdResponse; //} //if (wcIdentification.ImprovementType.Equals(EnumWcImprovementType.Additional.ToString(), StringComparison.OrdinalIgnoreCase)) //{ // if (!await IsWcIdentificationAlreadyExist(wcIdentification)) // { // wmsdResponse.ResponseCode = EnumStatus.NotFound; // wmsdResponse.ResponseMessage = "No Watercourse found with Regular Status."; // return wmsdResponse; // } //} if (await IsWcIdentificationAlreadyExist(wcIdentification)) { wmsdResponse.ResponseCode = EnumStatus.AlreadyExist; wmsdResponse.ResponseMessage = "Watercourse already exists."; return(wmsdResponse); } //Check if status is Addation than there must be a regular water course try { using (var _dbContext = new EntityContext()) { _dbContext.WcIdentifications.Add(wcIdentification); var response = await _dbContext.SaveChangesAsync(); if (response > 0) { wmsdResponse.ResponseCode = EnumStatus.Success;; wmsdResponse.ResponseMessage = "Identicification has been added successfully."; return(wmsdResponse); } else { wmsdResponse.ResponseCode = EnumStatus.Failed;; wmsdResponse.ResponseMessage = "Failed to add channel."; return(wmsdResponse); } } } catch (Exception ex) { wmsdResponse.ResponseCode = EnumStatus.InternalServer; wmsdResponse.ResponseMessage = ex.Message; return(wmsdResponse); } }
/// <summary> /// Step1: Update BasicInformation /// </summary> /// <param name="wcIdentificationDetail"></param> /// <returns></returns> public async Task <WmsdsResponse <int> > UpdateBasicInformation(WcIdentificationDetail wcIdentificationDetail) { var wmsdResponse = new WmsdsResponse <int>(); if (wcIdentificationDetail == null) { wmsdResponse.ResponseCode = EnumStatus.EmptyObject; wmsdResponse.ResponseMessage = "Object is empty."; return(wmsdResponse); } if (wcIdentificationDetail.WcIdentificationId <= 0) { wmsdResponse.ResponseCode = EnumStatus.EmptyObject; wmsdResponse.ResponseMessage = "Parent Identification key is empty."; return(wmsdResponse); } if (wcIdentificationDetail.Id <= 0) { wmsdResponse.ResponseCode = EnumStatus.EmptyObject; wmsdResponse.ResponseMessage = "Id is missing."; return(wmsdResponse); } try { using (var _dbContext = new EntityContext()) { var basicInfoDb = await _dbContext.WcIdentificationDetails .Where(c => c.Id == wcIdentificationDetail.Id && c.WcIdentificationId == wcIdentificationDetail.WcIdentificationId) .SingleOrDefaultAsync(); if (basicInfoDb != null) { basicInfoDb.ProjectId = wcIdentificationDetail.ProjectId <= 0 ? basicInfoDb.ProjectId: wcIdentificationDetail.ProjectId; basicInfoDb.ProjectName = string.IsNullOrEmpty(wcIdentificationDetail.ProjectName) ? basicInfoDb.ProjectName : wcIdentificationDetail.ProjectName; basicInfoDb.VillageName = string.IsNullOrEmpty(wcIdentificationDetail.VillageName) ? basicInfoDb.VillageName : wcIdentificationDetail.VillageName; basicInfoDb.UC = string.IsNullOrEmpty(wcIdentificationDetail.UC) ? basicInfoDb.UC : wcIdentificationDetail.UC; basicInfoDb.GCA = wcIdentificationDetail.GCA <= 0 ? basicInfoDb.GCA : wcIdentificationDetail.GCA; basicInfoDb.CCA = wcIdentificationDetail.CCA <= 0 ? basicInfoDb.CCA : wcIdentificationDetail.CCA; basicInfoDb.SanctionedDischargeLPS = wcIdentificationDetail.SanctionedDischargeLPS <= 0 ? basicInfoDb.SanctionedDischargeLPS : wcIdentificationDetail.SanctionedDischargeLPS; basicInfoDb.DesignDischargeLPS = wcIdentificationDetail.DesignDischargeLPS <= 0 ? basicInfoDb.DesignDischargeLPS : wcIdentificationDetail.DesignDischargeLPS; basicInfoDb.MoghaType = string.IsNullOrEmpty(wcIdentificationDetail.MoghaType) ? basicInfoDb.MoghaType : wcIdentificationDetail.MoghaType; basicInfoDb.GroundwaterQuality = string.IsNullOrEmpty(wcIdentificationDetail.GroundwaterQuality) ? basicInfoDb.GroundwaterQuality : wcIdentificationDetail.GroundwaterQuality; basicInfoDb.WUAChairman = string.IsNullOrEmpty(wcIdentificationDetail.WUAChairman) ? basicInfoDb.WUAChairman : wcIdentificationDetail.WUAChairman; basicInfoDb.NoOfBeneficiaries = wcIdentificationDetail.NoOfBeneficiaries <= 0 ? basicInfoDb.NoOfBeneficiaries : wcIdentificationDetail.NoOfBeneficiaries; basicInfoDb.TotalLengthM = wcIdentificationDetail.TotalLengthM <= 0 ? basicInfoDb.TotalLengthM : wcIdentificationDetail.TotalLengthM; basicInfoDb.PreviousLinedLengthM = wcIdentificationDetail.PreviousLinedLengthM <= 0 ? basicInfoDb.PreviousLinedLengthM : wcIdentificationDetail.PreviousLinedLengthM; basicInfoDb.Latitude = wcIdentificationDetail.Latitude <= 0 ? basicInfoDb.Latitude : wcIdentificationDetail.Latitude; basicInfoDb.Longitude = wcIdentificationDetail.Longitude <= 0 ? basicInfoDb.Longitude : wcIdentificationDetail.Longitude; var response = await _dbContext.SaveChangesAsync(); if (response > 0) { wmsdResponse.ResponseCode = EnumStatus.Success;; wmsdResponse.ResponseMessage = "Record has been added successfully."; return(wmsdResponse); } else { wmsdResponse.ResponseCode = EnumStatus.Failed;; wmsdResponse.ResponseMessage = "Failed to update record."; return(wmsdResponse); } } else { wmsdResponse.ResponseCode = EnumStatus.NotFound;; wmsdResponse.ResponseMessage = "No Record found against given Ids."; return(wmsdResponse); } } } catch (Exception ex) { wmsdResponse.ResponseCode = EnumStatus.InternalServer; wmsdResponse.ResponseMessage = ex.Message; return(wmsdResponse); } }
/// <summary> /// Step3: Add/Update ICR1 & ICR2 /// </summary> /// <param name="wcIdentificationDetail"></param> /// <returns></returns> public async Task <WmsdsResponse <int> > AddUpdateICR1AndICR2(WcIdentificationDetail wcIdentificationDetail) { var wmsdResponse = new WmsdsResponse <int>(); if (wcIdentificationDetail == null) { wmsdResponse.ResponseCode = EnumStatus.EmptyObject; wmsdResponse.ResponseMessage = "Object is empty."; return(wmsdResponse); } if (wcIdentificationDetail.WcIdentificationId <= 0) { wmsdResponse.ResponseCode = EnumStatus.EmptyObject; wmsdResponse.ResponseMessage = "Parent Identification key is empty."; return(wmsdResponse); } if (wcIdentificationDetail.Id <= 0) { wmsdResponse.ResponseCode = EnumStatus.EmptyObject; wmsdResponse.ResponseMessage = "Id is missing."; return(wmsdResponse); } try { using (var _dbContext = new EntityContext()) { var basicInfoDb = await _dbContext.WcIdentificationDetails .Where(c => c.Id == wcIdentificationDetail.Id && c.WcIdentificationId == wcIdentificationDetail.WcIdentificationId) .SingleOrDefaultAsync(); if (basicInfoDb != null) { basicInfoDb.ICR1ApprovedStatus = string.IsNullOrEmpty(wcIdentificationDetail.ICR1ApprovedStatus) ? basicInfoDb.ICR1ApprovedStatus : wcIdentificationDetail.ICR1ApprovedStatus; basicInfoDb.ICR1ReleasedAmount = wcIdentificationDetail.ICR1ReleasedAmount <= 0 ? basicInfoDb.ICR1ReleasedAmount : wcIdentificationDetail.ICR1ReleasedAmount; basicInfoDb.ICR2ApprovedStatus = string.IsNullOrEmpty(wcIdentificationDetail.ICR2ApprovedStatus) ? basicInfoDb.ICR2ApprovedStatus : wcIdentificationDetail.ICR2ApprovedStatus; basicInfoDb.ICR2ReleasedAmount = wcIdentificationDetail.ICR2ReleasedAmount <= 0 ? basicInfoDb.ICR2ReleasedAmount : wcIdentificationDetail.ICR2ReleasedAmount; var response = await _dbContext.SaveChangesAsync(); if (response > 0) { wmsdResponse.ResponseCode = EnumStatus.Success;; wmsdResponse.ResponseMessage = "Record has been updated successfully."; return(wmsdResponse); } else { wmsdResponse.ResponseCode = EnumStatus.Failed;; wmsdResponse.ResponseMessage = "Failed to update record."; return(wmsdResponse); } } else { wmsdResponse.ResponseCode = EnumStatus.NotFound;; wmsdResponse.ResponseMessage = "No Record found against given Ids."; return(wmsdResponse); } } } catch (Exception ex) { wmsdResponse.ResponseCode = EnumStatus.InternalServer; wmsdResponse.ResponseMessage = ex.Message; return(wmsdResponse); } }
public async Task <WmsdsResponse <DistrictWiseDto> > GetDistrictWiseOverview(int districtId) { var wmsdResponse = new WmsdsResponse <DistrictWiseDto>(); wmsdResponse.DataObject = new DistrictWiseDto(); try { using (var dbContext = new EntityContext()) { var improvedWcCount = await(from wc in dbContext.WcIdentifications from wd in dbContext.WcIdentificationDetails where wc.Id == wd.WcIdentificationId && wc.DistrictId == districtId select wc.Id).CountAsync(); var totalWcCourse = await dbContext.WaterCourses.Where(wc => wc.DistrictId == districtId).CountAsync(); wmsdResponse.DataObject.ImprovedWaterCourse = improvedWcCount; wmsdResponse.DataObject.UnImprovedWaterCourse = totalWcCourse - improvedWcCount; //Watercourse Improvement Status var wcImprovementStatus = await(from wc in dbContext.WcIdentifications from wd in dbContext.WcIdentificationDetails where wc.Id == wd.WcIdentificationId && wc.DistrictId == districtId group wd by new { wd.ImprovementType } into g select new KeyValueDto { name = g.Key.ImprovementType, y = g.Count(x => x.WcIdentificationId != 0) }).ToListAsync(); wmsdResponse.DataObject.KeyValueDtos = wcImprovementStatus; //Get Improved Length var wcImprovementLength = await(from wc in dbContext.WcIdentifications from wd in dbContext.WcIdentificationDetails where wc.Id == wd.WcIdentificationId && wc.DistrictId == districtId select wd).ToListAsync(); var earthenTotalLen = wcImprovementLength.Sum(x => x.EarthenLengthM); var linedTotalLen = wcImprovementLength.Sum(x => x.LiningLengthM); wmsdResponse.ResponseCode = EnumStatus.Success; wmsdResponse.DataObject.Earthen = (int)earthenTotalLen / 1000;//KM //wmsdResponse.DataObject.Earthen = wmsdResponse.DataObject.Earthen / 1000;//"000KM" wmsdResponse.DataObject.Lined = (int)linedTotalLen / 1000;//KM // wmsdResponse.DataObject.Lined = wmsdResponse.DataObject.Lined / 1000;//"000KM" wmsdResponse.DataObject.TotalLength = wmsdResponse.DataObject.Earthen + wmsdResponse.DataObject.Lined; //Tehsil wise Watercourse Improvement var tehsilWiseData = await(from wc in dbContext.WcIdentifications from wd in dbContext.WcIdentificationDetails where wc.Id == wd.WcIdentificationId && wc.DistrictId == districtId group wd by new { wc.TehsilName, wc.TehsilId } into g select new { Tehsil = g.Key.TehsilName, TehsilId = g.Key.TehsilId }).ToListAsync(); wmsdResponse.DataObject.TehsilWiseDtos = new List <TehsilWiseDto>(); foreach (var tehsilWise in tehsilWiseData) { var tehsilWiseDto = new TehsilWiseDto(); var tehsilWiseCount = await(from wc in dbContext.WcIdentifications from wd in dbContext.WcIdentificationDetails where wc.Id == wd.WcIdentificationId && wc.DistrictId == districtId && wc.TehsilId == tehsilWise.TehsilId select wc.Id).CountAsync(); var totalWcCourseThWise = await dbContext.WaterCourses .Where(wc => wc.DistrictId == districtId && wc.TehsilId == tehsilWise.TehsilId).CountAsync(); tehsilWiseDto.ImprovedWaterCourse = tehsilWiseCount; tehsilWiseDto.UnImprovedWaterCourse = totalWcCourseThWise - tehsilWiseCount; tehsilWiseDto.Tehsil = tehsilWise.Tehsil; wmsdResponse.DataObject.TehsilWiseDtos.Add(tehsilWiseDto); } wmsdResponse.ResponseCode = EnumStatus.Success; wmsdResponse.ResponseMessage = "Success"; return(wmsdResponse); } } catch (Exception ex) { wmsdResponse.ResponseCode = EnumStatus.Error; wmsdResponse.ResponseMessage = ex.Message; return(wmsdResponse); } }
/// <summary> /// Step4: Add Update FCR /// </summary> /// <param name="wcIdentificationDetail"></param> /// <returns></returns> public async Task <WmsdsResponse <int> > AddUpdateFCR(WcIdentificationDetail wcIdentificationDetail) { var wmsdResponse = new WmsdsResponse <int>(); if (wcIdentificationDetail == null) { wmsdResponse.ResponseCode = EnumStatus.EmptyObject; wmsdResponse.ResponseMessage = "Object is empty."; return(wmsdResponse); } if (wcIdentificationDetail.WcIdentificationId <= 0) { wmsdResponse.ResponseCode = EnumStatus.EmptyObject; wmsdResponse.ResponseMessage = "Parent Identification key is empty."; return(wmsdResponse); } if (wcIdentificationDetail.Id <= 0) { wmsdResponse.ResponseCode = EnumStatus.EmptyObject; wmsdResponse.ResponseMessage = "Id is missing."; return(wmsdResponse); } try { using (var _dbContext = new EntityContext()) { var basicInfoDb = await _dbContext.WcIdentificationDetails .Where(c => c.Id == wcIdentificationDetail.Id && c.WcIdentificationId == wcIdentificationDetail.WcIdentificationId) .SingleOrDefaultAsync(); if (basicInfoDb != null) { basicInfoDb.FCRApprovedStatus = string.IsNullOrEmpty(wcIdentificationDetail.FCRApprovedStatus) ? basicInfoDb.FCRApprovedStatus : wcIdentificationDetail.FCRApprovedStatus; basicInfoDb.FCRLinedLength = wcIdentificationDetail.FCRLinedLength <= 0 ? basicInfoDb.FCRLinedLength : wcIdentificationDetail.FCRLinedLength; basicInfoDb.LinedPercentage = wcIdentificationDetail.LinedPercentage <= 0 ? basicInfoDb.LinedPercentage : wcIdentificationDetail.LinedPercentage; basicInfoDb.TotalCostOfCivilWrkVerfied = wcIdentificationDetail.TotalCostOfCivilWrkVerfied <= 0 ? basicInfoDb.TotalCostOfCivilWrkVerfied : wcIdentificationDetail.TotalCostOfCivilWrkVerfied; basicInfoDb.FCREarthenWorks = wcIdentificationDetail.FCREarthenWorks <= 0 ? basicInfoDb.FCREarthenWorks : wcIdentificationDetail.FCREarthenWorks; basicInfoDb.FCRMasonryWorks = wcIdentificationDetail.FCRMasonryWorks <= 0 ? basicInfoDb.FCRMasonryWorks : wcIdentificationDetail.FCRMasonryWorks; basicInfoDb.TotalSchemeCost = wcIdentificationDetail.TotalSchemeCost <= 0 ? basicInfoDb.TotalSchemeCost : wcIdentificationDetail.TotalSchemeCost; basicInfoDb.FCRPcpSegmentSize = string.IsNullOrEmpty(wcIdentificationDetail.FCRPcpSegmentSize) ? basicInfoDb.FCRPcpSegmentSize : wcIdentificationDetail.FCRPcpSegmentSize; basicInfoDb.FCRPcpSegment = wcIdentificationDetail.FCRPcpSegment <= 0 ? basicInfoDb.FCRPcpSegment : wcIdentificationDetail.FCRPcpSegment; basicInfoDb.FCRPipeType = string.IsNullOrEmpty(wcIdentificationDetail.FCRPipeType) ? basicInfoDb.FCRPipeType : wcIdentificationDetail.FCRPipeType; basicInfoDb.FCRSizeOfPipeInch = wcIdentificationDetail.FCRSizeOfPipeInch <= 0 ? basicInfoDb.FCRSizeOfPipeInch : wcIdentificationDetail.FCRSizeOfPipeInch; basicInfoDb.FCRLengthOfPipeM = wcIdentificationDetail.FCRLengthOfPipeM <= 0 ? basicInfoDb.FCRLengthOfPipeM : wcIdentificationDetail.FCRLengthOfPipeM; basicInfoDb.FCRNakkas = wcIdentificationDetail.FCRNakkas <= 0 ? basicInfoDb.FCRNakkas : wcIdentificationDetail.FCRNakkas; basicInfoDb.FCRCulverts = wcIdentificationDetail.FCRCulverts <= 0 ? basicInfoDb.FCRCulverts : wcIdentificationDetail.FCRCulverts; basicInfoDb.FCRBuffaloWallow = wcIdentificationDetail.FCRBuffaloWallow <= 0 ? basicInfoDb.FCRBuffaloWallow : wcIdentificationDetail.FCRBuffaloWallow; basicInfoDb.FCRDistributionBox = wcIdentificationDetail.FCRDistributionBox <= 0 ? basicInfoDb.FCRDistributionBox : wcIdentificationDetail.FCRDistributionBox; basicInfoDb.FCRWaterStorageTank = wcIdentificationDetail.FCRWaterStorageTank <= 0 ? basicInfoDb.FCRWaterStorageTank : wcIdentificationDetail.FCRWaterStorageTank; basicInfoDb.FCRDropStructure = wcIdentificationDetail.FCRDropStructure <= 0 ? basicInfoDb.FCRDropStructure : wcIdentificationDetail.FCRDropStructure; basicInfoDb.FCROthers = wcIdentificationDetail.FCROthers <= 0 ? basicInfoDb.FCROthers : wcIdentificationDetail.FCROthers; var response = await _dbContext.SaveChangesAsync(); if (response > 0) { wmsdResponse.ResponseCode = EnumStatus.Success;; wmsdResponse.ResponseMessage = "Record has been updated successfully."; return(wmsdResponse); } else { wmsdResponse.ResponseCode = EnumStatus.Failed;; wmsdResponse.ResponseMessage = "Failed to update record."; return(wmsdResponse); } } else { wmsdResponse.ResponseCode = EnumStatus.NotFound;; wmsdResponse.ResponseMessage = "No Record found against given Ids."; return(wmsdResponse); } } } catch (Exception ex) { wmsdResponse.ResponseCode = EnumStatus.InternalServer; wmsdResponse.ResponseMessage = ex.Message; return(wmsdResponse); } }