/// <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 <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); } }
public async Task <ActionResult> AddUpdateWorksExecuted(FormCollection formCollection) { try { int HeisIdentificationId = Convert.ToInt16(formCollection["hdHeisIdentificationIdWorksExecuted"] + ""); int HeisIdentificationDetailId = Convert.ToInt16(formCollection["hdHeisIdentificationDetailsIdWorksExecuted"] + ""); string WorkOrderIssued = formCollection["ddlWorkOrderIssued"] + "".Replace("--Select--", ""); DateTime WorkOrderIssueDate = DateTime.Now; try { WorkOrderIssueDate = DateTime.ParseExact(formCollection["txtWorkOrderIssueDate"].ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture); } catch (Exception) { } decimal WorkOrderAmount = Convert.ToDecimal(formCollection["txtWorkOrderAmount"]); decimal EstimatedGovtShare = Convert.ToDecimal(formCollection["txtEstimatedGovtShare"]); decimal EstimatedFamerShare = Convert.ToDecimal(formCollection["txtEstimatedFamerShare"]); decimal FarmerShareInCash = Convert.ToDecimal(formCollection["txtFarmerShareInCash"]); decimal FarmerShareInKind = Convert.ToDecimal(formCollection["txtFarmerShareInKind"]); string MaterialVerified = formCollection["ddlMaterialVerified"] + "".Replace("--Select--", ""); DateTime MaterialVerifiedDate = DateTime.Now; try { MaterialVerifiedDate = DateTime.ParseExact(formCollection["txtMaterialVerifiedDate"].ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture); } catch (Exception) { } int ICRIAmountVerified = Convert.ToInt16(formCollection["txtICRIAmountVerified"]); string CommissioningVerification = formCollection["ddlCommissioningVerification"] + "".Replace("--Select--", ""); DateTime CommissioningVerificationDate = DateTime.Now; try { CommissioningVerificationDate = DateTime.ParseExact(formCollection["txtCommissioningVerificationDate"].ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture); } catch (Exception) { } int TotalSchemeCostVerified = Convert.ToInt16(formCollection["txtTotalSchemeCostVerified"]); int ICRIIAmountVerified = Convert.ToInt16(formCollection["txtICRIIAmountVerified"]); string ICRIIIVerification = formCollection["ddlICRIIIVerification"] + "".Replace("--Select--", ""); int TotalAmountVerified = Convert.ToInt16(formCollection["txtTotalAmountVerified"]); DateTime ICRIIIQualifyingDate = DateTime.Now; try { ICRIIIQualifyingDate = DateTime.ParseExact(formCollection["txtICRIIIQualifyingDate"].ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture); } catch (Exception) { } HeisIdentificationDetail heisIdentificationDetail = new HeisIdentificationDetail(); heisIdentificationDetail.HeisIdentificationId = HeisIdentificationId; heisIdentificationDetail.Id = HeisIdentificationDetailId; heisIdentificationDetail.WorkOrderIssued = WorkOrderIssued; heisIdentificationDetail.WorkOrderIssueDate = WorkOrderIssueDate; heisIdentificationDetail.WorkOrderAmount = WorkOrderAmount; heisIdentificationDetail.EstimatedGovtShare = EstimatedGovtShare; heisIdentificationDetail.EstimatedFamerShare = EstimatedFamerShare; heisIdentificationDetail.FarmerShareInCash = FarmerShareInCash; heisIdentificationDetail.FarmerShareInKind = FarmerShareInKind; heisIdentificationDetail.MaterialVerified = MaterialVerified; heisIdentificationDetail.MaterialVerifiedDate = MaterialVerifiedDate; heisIdentificationDetail.ICRIAmountVerified = ICRIAmountVerified; heisIdentificationDetail.CommissioningVerification = CommissioningVerification; heisIdentificationDetail.CommissioningVerificationDate = CommissioningVerificationDate; heisIdentificationDetail.TotalSchemeCostVerified = TotalSchemeCostVerified; heisIdentificationDetail.ICRIIAmountVerified = ICRIIAmountVerified; heisIdentificationDetail.ICRIIIVerification = ICRIIIVerification; heisIdentificationDetail.TotalAmountVerified = TotalAmountVerified; heisIdentificationDetail.ICRIIIQualifyingDate = ICRIIIQualifyingDate; IHeisService heisService = new HeisService(); var response = await heisService.AddWorksExecuted(heisIdentificationDetail); if (response.ResponseCode == Entities.EnumStatus.Success) { } return(Json(new { FormId = 0, HttpStatusCode = (int)HttpStatusCode.OK })); } catch (Exception ex) { return(Json(new { FormId = 0, HttpStatusCode = HttpStatusCode.NotImplemented })); } }
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 <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 })); } }