public bool InsertUpdate(PrincipaleConstantOfVolunteerViewModel model) { using (SamajkalyanEntities ent = new SamajkalyanEntities()) { try { var generalAgreementRow = ent.PrincipaleConstantOfVolunters.Where(x => x.VolunteerID == model.VolunteerID).FirstOrDefault(); if (generalAgreementRow == null) { generalAgreementRow = new PrincipaleConstantOfVolunter(); } ; generalAgreementRow.GA_Id = model.GA_Id; generalAgreementRow.PA_Id = model.PA_Id; generalAgreementRow.Council_sRagistrationNumber = model.Council_sRagistrationNumber; generalAgreementRow.C_Council_sRagistrationDate = model.C_Council_sRagistrationDate; generalAgreementRow.C_Council_sRagistrationDateNp = model.C_Council_sRagistrationDateNp; generalAgreementRow.NameOfAppicant = model.NameOfAppicant; generalAgreementRow.Country = model.Country; generalAgreementRow.PassportNumber = model.PassportNumber; generalAgreementRow.VisaDuration = model.VisaDuration; generalAgreementRow.ApplicationDesingation = model.ApplicationDesingation; generalAgreementRow.ApplicationSector = model.ApplicationSector; generalAgreementRow.Agreement = model.Agreement; generalAgreementRow.ServiceReciverNGOSName = model.ServiceReciverNGOSName; generalAgreementRow.DecisionDate = model.DecisionDate; generalAgreementRow.DecisionDateNp = model.DecisionDateNp; generalAgreementRow.Remarks = model.Remarks; generalAgreementRow.CreatedDate = model.CreatedDate; generalAgreementRow.CreateedBy = model.CreateedBy; if (model.VolunteerID == 0) { // generalAgreementRow.Status = false; ent.PrincipaleConstantOfVolunters.Add(generalAgreementRow); ent.SaveChanges(); } else { // deploymentRow.Status = dmodel.Status ?? false; generalAgreementRow.UpdateDate = model.UpdateDate; generalAgreementRow.UpdatedBy = model.UpdatedBy; ent.PrincipaleConstantOfVolunters.Attach(generalAgreementRow); ent.Entry(generalAgreementRow).State = EntityState.Modified; ent.SaveChanges(); } } catch (Exception ex) { return(false); } } return(true); }
public bool Insert(IngoTerminationViewModel model) { using (SamajkalyanEntities ent = new SamajkalyanEntities()) { try { var Row = ent.IngoTerminations.Where(x => x.TerminationId == model.TerminationId).FirstOrDefault(); //_context.Database.Connection.Open(); //_context.Database.Connection.BeginTransaction(); if (Row == null) { Row = new IngoTermination(); } ; Row.NameOfAssest = model.NameOfAssest; Row.TerminationDate = model.TerminationDate; Row.TerminationDateNp = model.TerminationDateNp; Row.IngoId = model.IngoId; Row.EvaluationOfReportAttached = model.EvaluationOfReportAttached; //deploymentRow.Status = true; if (model.TerminationId == 0) { // generalAgreementRow.Status = false; Row.CreatedDate = model.DeletdDate; Row.CreatedBy = model.CreatedBy; ent.IngoTerminations.Add(Row); ent.SaveChanges(); } else { // deploymentRow.Status = dmodel.Status ?? false; Row.UpdateBy = model.UpdateBy; Row.UpdateDate = model.UpdateDate; ent.IngoTerminations.Attach(Row); ent.Entry(Row).State = EntityState.Modified; ent.SaveChanges(); } //if (model.TerminationId <= 0) //{ // model.GeneralAgreement_ID = ent.Database.SqlQuery<GeneralAgreementViewModel>("select * from GeneralAgreement where GeneralAgreement_ID=(select max (GeneralAgreement_ID) from GeneralAgreement )").ToList().FirstOrDefault().GeneralAgreement_ID; // //employeeRow.EmpId=employeeRow.EmpId != 0 ? employeeRow.EmpId : empModel.EmpId; //} } catch (Exception ex) { return(false); } } return(true); }
public int Delete(int id) { SamajkalyanEntities ent = new SamajkalyanEntities(); try { //delete Deployment employee //delete Deplpoyment var obj = ent.ProjectAgreements.ToList().Where(x => x.ProjectAgreement_ID == id).FirstOrDefault(); obj.DeletedDate = DateTime.Now; //_context.DeploymentTbls.Remove(obj); int i = ent.SaveChanges(); if (i > 0) { return(1); } } catch (Exception ex) { return(0); } return(0); }
public bool InsertUpdateWorkPermitType(WorkPermitTypeViewModel model) { using (SamajkalyanEntities ent = new SamajkalyanEntities()) { try { var workPermitTypeRow = ent.WorKPermitTypes.Where(x => x.WorkPermitTypeId == model.WorkPermitTypeId).FirstOrDefault(); //_context.Database.Connection.Open(); //_context.Database.Connection.BeginTransaction(); if (workPermitTypeRow == null) { workPermitTypeRow = new WorKPermitType(); } ; workPermitTypeRow.Name = model.Name; workPermitTypeRow.CreatedBy = model.CreatedBy; workPermitTypeRow.CreatedDate = model.CreatedDate; //deploymentRow.Status = true; if (model.WorkPermitTypeId == 0) { // generalAgreementRow.Status = false; ent.WorKPermitTypes.Add(workPermitTypeRow); ent.SaveChanges(); } else { // deploymentRow.Status = dmodel.Status ?? false; workPermitTypeRow.UpdatedBy = model.UpdatedBy; workPermitTypeRow.UdatedDate = model.UdatedDate; ent.WorKPermitTypes.Attach(workPermitTypeRow); ent.Entry(workPermitTypeRow).State = EntityState.Modified; ent.SaveChanges(); } } catch (Exception ex) { return(false); } } return(true); }
public bool InsertGeneralAgreement(GeneralAgreementViewModel model) { using (SamajkalyanEntities ent = new SamajkalyanEntities()) { var GAEntity = new GeneralAgreement() { // Ethnic_ID = model.Ethnic_ID, Name_Of_Ingo = model.Name_Of_Ingo, Name_of_Ingo_Nepali = model.Name_of_Ingo_Nepali, Ga_Date = model.Ga_Date, Ga_Date_Nepali = model.Ga_Date_Nepali, Period = model.Period, Pre_Annum_Commitment_Amount = model.Pre_Annum_Commitment_Amount, Ga_Service_Charge = model.Ga_Service_Charge, Sector = model.Sector, Hq_Address = model.Hq_Address, Contact_Person = model.Contact_Person, Country_Official_Nepal_Address = model.Country_Official_Nepal_Address, Contact_Number = model.Contact_Number, Email = model.Email, GA_TerminationDate = model.GA_TerminationDate, Ga_TerminationDate_Nepali = model.Ga_TerminationDate_Nepali, PA_Attachment_Location = model.PA_Attachment_Location, Scan_GA_Location = model.Scan_GA_Location, CreatedBy = model.CreatedBy, DeletedBy = model.DeletedBy, UpdatedBy = model.UpdatedBy, UpdatedDate = model.UpdatedDate, CreatedDate = DateTime.Now, }; ent.GeneralAgreements.Add(GAEntity); int i = ent.SaveChanges(); if (i > 0) { return(true); } else { return(false); } } }
public int Delete(int id) { try { var obj = ent.VehicleAuctions.Where(x => x.VehicleAuctionId == id).FirstOrDefault(); obj.DeletedDate = DateTime.Now; int i = ent.SaveChanges(); if (i > 0) { return(1); } } catch (Exception ex) { return(0); } return(0); }
public int Delete(int id) { try { var obj = ent.PrincipaleConstantOfVolunters.ToList().Where(x => x.VolunteerID == id).FirstOrDefault(); obj.DeletedDate = DateTime.Now; int i = ent.SaveChanges(); if (i > 0) { return(1); } } catch (Exception ex) { return(0); } return(0); }
public int Delete(int id) { try { var obj = ent.Import_DutyFreeRecommendation.Where(x => x.ImportId == id).FirstOrDefault(); obj.DeletedDate = DateTime.Now; int i = ent.SaveChanges(); if (i > 0) { return(1); } } catch (Exception ex) { return(0); } return(0); }
public int Delete(int id) { try { var obj = ent.HandOver_TakeOver.Where(x => x.HandOver_TakeOverId == id).FirstOrDefault(); obj.DeletedDate = DateTime.Now; int i = ent.SaveChanges(); if (i > 0) { return(1); } } catch (Exception ex) { return(0); } return(0); }
public int Delete(int id) { try { //delete Deployment employee //delete Deplpoyment var obj = ent.WorkPermits.Where(x => x.WorkPermitId == id).FirstOrDefault(); obj.DeletedDate = DateTime.Now; //_context.DeploymentTbls.Remove(obj); int i = ent.SaveChanges(); if (i > 0) { return(1); } } catch (Exception ex) { return(0); } return(0); }
public bool InsertGeneralAgreement2(GeneralAgreementViewModel model) { using (SamajkalyanEntities ent = new SamajkalyanEntities()) { try { var generalAgreementRow = ent.GeneralAgreements.Where(x => x.GeneralAgreement_ID == model.GeneralAgreement_ID).FirstOrDefault(); //_context.Database.Connection.Open(); //_context.Database.Connection.BeginTransaction(); if (generalAgreementRow == null) { generalAgreementRow = new GeneralAgreement(); } ; generalAgreementRow.Name_Of_Ingo = model.Name_Of_Ingo; generalAgreementRow.Name_of_Ingo_Nepali = model.Name_of_Ingo_Nepali; generalAgreementRow.Ga_Date = model.Ga_Date; generalAgreementRow.Ga_Date_Nepali = model.Ga_Date_Nepali; generalAgreementRow.Period = model.Period; generalAgreementRow.Pre_Annum_Commitment_Amount = model.Pre_Annum_Commitment_Amount; generalAgreementRow.Ga_Service_Charge = model.Ga_Service_Charge; generalAgreementRow.Sector = model.Sector; generalAgreementRow.Hq_Address = model.Hq_Address; generalAgreementRow.Contact_Person = model.Contact_Person; generalAgreementRow.Country_Official_Nepal_Address = model.Country_Official_Nepal_Address; generalAgreementRow.Contact_Number = model.Contact_Number; generalAgreementRow.Email = model.Email; generalAgreementRow.GA_TerminationDate = model.GA_TerminationDate; generalAgreementRow.Ga_TerminationDate_Nepali = model.Ga_TerminationDate_Nepali; generalAgreementRow.Scan_GA_Location = model.Scan_GA_Location; generalAgreementRow.PA_Attachment_Location = model.PA_Attachment_Location; generalAgreementRow.Country = model.Country; //deploymentRow.Status = true; if (model.GeneralAgreement_ID == 0) { // generalAgreementRow.Status = false; ent.GeneralAgreements.Add(generalAgreementRow); ent.SaveChanges(); } else { // deploymentRow.Status = dmodel.Status ?? false; ent.GeneralAgreements.Attach(generalAgreementRow); ent.Entry(generalAgreementRow).State = EntityState.Modified; ent.SaveChanges(); } if (model.GeneralAgreement_ID <= 0) { model.GeneralAgreement_ID = ent.Database.SqlQuery <GeneralAgreementViewModel>("select * from GeneralAgreement where GeneralAgreement_ID=(select max (GeneralAgreement_ID) from GeneralAgreement )").ToList().FirstOrDefault().GeneralAgreement_ID; //employeeRow.EmpId=employeeRow.EmpId != 0 ? employeeRow.EmpId : empModel.EmpId; } // #region files // using (var tempContext = new SamajkalyanEntities()) // { // var deletelist = tempContext.GA_Attachment.Where(x => x.GeneralAgreement_ID == model.GeneralAgreement_ID).ToList(); // if (deletelist.Count > 0) // { // foreach (var item in deletelist) // { // if (model.GaAttachmentViewModelList == null) // { // model.GaAttachmentViewModelList = new List<GaAttachmentViewModel>(); // } // var isExists = model.GaAttachmentViewModelList.Where(x => x.GA_Attachment_ID == item.GeneralAgreement_ID).FirstOrDefault(); // if (isExists == null) // { // tempContext.GA_Attachment.Remove(item); // tempContext.SaveChanges(); // } // } // } // } // if (model.GaAttachmentViewModelList != null) // { // foreach (var item in model.GaAttachmentViewModelList) // { // GA_Attachment newRow = new GA_Attachment(); // newRow.GeneralAgreement_ID = model.GeneralAgreement_ID; // newRow.GA_Attachment_ID = item.GA_Attachment_ID; // newRow.PA_Attachment_Location = item.PA_Attachment_Location; // newRow.Scan_GA_Location = item.Scan_GA_Location; // //newRow.NoOfDep = item.NoOfDep; // if (item.GA_Attachment_ID == 0) // { // ent.GA_Attachment.Add(newRow); // ent.SaveChanges(); // } // else // { // ent.GA_Attachment.Attach(newRow); // ent.Entry(newRow).State = EntityState.Modified; // ent.SaveChanges(); // } // } // } } catch (Exception ex) { return(false); } } return(true); }
public bool InsertUpdateWorkPermit(WorkPermitViewModel model) { using (SamajkalyanEntities ent = new SamajkalyanEntities()) { try { var workPermitRow = ent.WorkPermits.Where(x => x.WorkPermitId == model.WorkPermitId).FirstOrDefault(); //_context.Database.Connection.Open(); //_context.Database.Connection.BeginTransaction(); if (workPermitRow == null) { workPermitRow = new WorkPermit(); } ; // workPermitRow.WorkPermitId = model.WorkPermitId; workPermitRow.GA_Id = model.GA_Id; workPermitRow.PA_Id = model.PA_Id; workPermitRow.WorkPermitTypeId = model.WorkPermitTypeId; workPermitRow.NameOfApplicant = model.NameOfApplicant; workPermitRow.Council_sRegistrationNumber = model.Council_sRegistrationNumber; workPermitRow.CouncilRegistrationDate = model.CouncilRegistrationDate; workPermitRow.CouncilRegistrationDateNp = model.CouncilRegistrationDateNp; workPermitRow.Country = model.Country; workPermitRow.PassportNumber = model.PassportNumber; workPermitRow.VisaDuration = model.VisaDuration; workPermitRow.ApplicationDesingation = model.ApplicationDesingation; workPermitRow.DecisionDate = model.DecisionDate; workPermitRow.VisaType = model.VisaType; workPermitRow.Remarks = model.Remarks; workPermitRow.CreatedBy = model.CreatedBy; workPermitRow.CreatedDate = model.CreatedDate; //deploymentRow.Status = true; if (model.WorkPermitId == 0) { // generalAgreementRow.Status = false; ent.WorkPermits.Add(workPermitRow); ent.SaveChanges(); } else { // deploymentRow.Status = dmodel.Status ?? false; workPermitRow.UpDatedBy = model.UpDatedBy; workPermitRow.UpdatedDate = model.UpdatedDate; ent.WorkPermits.Attach(workPermitRow); ent.Entry(workPermitRow).State = EntityState.Modified; ent.SaveChanges(); } if (model.WorkPermitId <= 0) { model.WorkPermitId = ent.Database.SqlQuery <WorkPermitViewModel>("select * from WorkPermit where WorkPermitId=(select max (WorkPermitId) from WorkPermit )").ToList().FirstOrDefault().WorkPermitId; //employeeRow.EmpId=employeeRow.EmpId != 0 ? employeeRow.EmpId : empModel.EmpId; } #region WP_FAmily using (var tempContext = new SamajkalyanEntities()) { var deletelist = tempContext.WpaFamilies.Where(x => x.WorkPermitId == model.WorkPermitId).ToList(); if (deletelist.Count > 0) { foreach (var item in deletelist) { if (model.WpaFamilyViewModelList == null) { model.WpaFamilyViewModelList = new List <WpaFamilyViewModel>(); } var isExists = model.WpaFamilyViewModelList.Where(x => x.WPAFamilyId == item.WPAFamilyId).FirstOrDefault(); if (isExists == null) { tempContext.WpaFamilies.Remove(item); tempContext.SaveChanges(); } } } } if (model.WpaFamilyViewModelList != null) { foreach (var item in model.WpaFamilyViewModelList) { WpaFamily newRow = new WpaFamily(); newRow.WorkPermitId = model.WorkPermitId; newRow.WPAFamilyId = item.WPAFamilyId; newRow.Name = item.Name; newRow.Country = item.Country; newRow.PassportNO = item.PassportNO; newRow.VisaDuration = item.VisaDuration; newRow.VisaType = item.VisaType; newRow.DicisionDate = item.DeletdDate; newRow.DicisionDateNp = item.DicisionDateNp; newRow.Relation = item.Relation; newRow.remark = item.remark; //newRow.NoOfDep = item.NoOfDep; if (item.WPAFamilyId == 0) { ent.WpaFamilies.Add(newRow); ent.SaveChanges(); } else { ent.WpaFamilies.Attach(newRow); ent.Entry(newRow).State = EntityState.Modified; ent.SaveChanges(); } } } #endregion } catch (Exception ex) { return(false); } } return(true); }
public bool InsertUpdate(HandOver_TakeOverViewModel model) { using (SamajkalyanEntities ent = new SamajkalyanEntities()) { try { var workPermitRow = ent.HandOver_TakeOver.Where(x => x.HandOver_TakeOverId == model.HandOver_TakeOverId).FirstOrDefault(); if (workPermitRow == null) { workPermitRow = new HandOver_TakeOver(); } ; workPermitRow.GA_Id = model.GA_Id; workPermitRow.PA_Id = model.PA_Id; workPermitRow.ApplicationRegistrationNumber = model.ApplicationRegistrationNumber; workPermitRow.RegistrationDate = model.RegistrationDate; workPermitRow.AssestReciverName = model.AssestReciverName; workPermitRow.DetailsOfAssest = model.DetailsOfAssest; workPermitRow.SummaryOfDecision = model.SummaryOfDecision; workPermitRow.RegistrationDateNp = model.RegistrationDateNp; workPermitRow.TotalValueOfAssest = model.TotalValueOfAssest; workPermitRow.DecisionDate = model.DecisionDate; workPermitRow.DecisionDateNp = model.DecisionDateNp; workPermitRow.Remarks = model.Remarks; workPermitRow.CreatedBy = model.CreatedBy; workPermitRow.CreatedDate = model.CreatedDate; if (model.HandOver_TakeOverId == 0) { ent.HandOver_TakeOver.Add(workPermitRow); ent.SaveChanges(); } else { workPermitRow.UpdatedBy = model.UpdatedBy; workPermitRow.UpdateDate = model.UpdateDate; ent.HandOver_TakeOver.Attach(workPermitRow); ent.Entry(workPermitRow).State = EntityState.Modified; ent.SaveChanges(); } //if (model.ImportId <= 0) //{ // model.ImportId = ent.Database.SqlQuery<WorkPermitViewModel>("select * from WorkPermit where WorkPermitId=(select max (WorkPermitId) from WorkPermit )").ToList().FirstOrDefault().WorkPermitId; // //employeeRow.EmpId=employeeRow.EmpId != 0 ? employeeRow.EmpId : empModel.EmpId; //} } catch (Exception ex) { return(false); } } return(true); }
public bool InsertImport_DutyFreeRecommendation(Import_DutyFreeRecommendationViewModel model) { using (SamajkalyanEntities ent = new SamajkalyanEntities()) { try { var workPermitRow = ent.Import_DutyFreeRecommendation.Where(x => x.ImportId == model.ImportId).FirstOrDefault(); //_context.Database.Connection.Open(); //_context.Database.Connection.BeginTransaction(); if (workPermitRow == null) { workPermitRow = new Import_DutyFreeRecommendation(); } ; // workPermitRow.WorkPermitId = model.WorkPermitId; workPermitRow.GA_Id = model.GA_Id; workPermitRow.PA_Id = model.PA_Id; workPermitRow.Council_RegistrtionNumber = model.Council_RegistrtionNumber; workPermitRow.CouncilRegistrationDate = model.CouncilRegistrationDate; workPermitRow.CouncilRegistrationDateNp = model.CouncilRegistrationDateNp; workPermitRow.DonnerName = model.DonnerName; workPermitRow.DonnerAddress = model.DonnerAddress; workPermitRow.DiscriptionOfGoods = model.DiscriptionOfGoods; workPermitRow.InvoiceDateNp = model.InvoiceDateNp; workPermitRow.DecisionDate = model.DecisionDate; workPermitRow.InvoiceNumber = model.InvoiceNumber; workPermitRow.TotalAmountForieignCurrency = model.TotalAmountForieignCurrency; workPermitRow.TotalAmountNepaliCurrency = model.TotalAmountNepaliCurrency; workPermitRow.Remarks = model.Remarks; workPermitRow.CreatedBy = model.CreatedBy; workPermitRow.CreatedDate = model.CreatedDate; //deploymentRow.Status = true; if (model.ImportId == 0) { // generalAgreementRow.Status = false; ent.Import_DutyFreeRecommendation.Add(workPermitRow); ent.SaveChanges(); } else { // deploymentRow.Status = dmodel.Status ?? false; workPermitRow.UpDatedBy = model.UpDatedBy; workPermitRow.UpdateDate = model.UpdateDate; ent.Import_DutyFreeRecommendation.Attach(workPermitRow); ent.Entry(workPermitRow).State = EntityState.Modified; ent.SaveChanges(); } //if (model.ImportId <= 0) //{ // model.ImportId = ent.Database.SqlQuery<WorkPermitViewModel>("select * from WorkPermit where WorkPermitId=(select max (WorkPermitId) from WorkPermit )").ToList().FirstOrDefault().WorkPermitId; // //employeeRow.EmpId=employeeRow.EmpId != 0 ? employeeRow.EmpId : empModel.EmpId; //} } catch (Exception ex) { return(false); } } return(true); }
public bool InsertProjectAgreement(ProjectAgreementViewModel model) { using (SamajkalyanEntities ent = new SamajkalyanEntities()) { try { var projectAgreementRow = ent.ProjectAgreements.Where(x => x.ProjectAgreement_ID == model.ProjectAgreement_ID).FirstOrDefault(); //_context.Database.Connection.Open(); //_context.Database.Connection.BeginTransaction(); if (projectAgreementRow == null) { projectAgreementRow = new ProjectAgreement(); } ; projectAgreementRow.GeneralAgreement_ID = model.GeneralAgreement_ID; projectAgreementRow.Name_Of_Project = model.Name_Of_Project; projectAgreementRow.Name_Of_Project_Nepali = model.Name_Of_Project_Nepali; projectAgreementRow.Name_Of_Bank = model.Name_Of_Bank; projectAgreementRow.PA_Sign_Date = model.PA_Sign_Date; projectAgreementRow.Project_Period = model.Project_Period; projectAgreementRow.Total_Budget = model.Total_Budget; projectAgreementRow.Admin_Cost = model.Admin_Cost; projectAgreementRow.Program_Cost = model.Program_Cost; projectAgreementRow.Name_Of_Bank = model.Name_Of_Bank; projectAgreementRow.Account_NO = model.Account_NO; projectAgreementRow.Doner = model.Doner; projectAgreementRow.No_Of_Expertriate = model.No_Of_Expertriate; projectAgreementRow.CreatedBy = model.CreatedBy; projectAgreementRow.CreatedDate = DateTime.Now; projectAgreementRow.Pa_Sign_DateNepali = model.Pa_Sign_DateNepali; //deploymentRow.Status = true; if (model.ProjectAgreement_ID == 0) { // generalAgreementRow.Status = false; ent.ProjectAgreements.Add(projectAgreementRow); ent.SaveChanges(); } else { // deploymentRow.Status = dmodel.Status ?? false; projectAgreementRow.UpDatedBy = model.UpDatedBy; projectAgreementRow.UpDatedDaye = DateTime.Now; ent.ProjectAgreements.Attach(projectAgreementRow); ent.Entry(projectAgreementRow).State = EntityState.Modified; ent.SaveChanges(); } if (model.ProjectAgreement_ID <= 0) { model.ProjectAgreement_ID = ent.Database.SqlQuery <ProjectAgreementViewModel>("select * from ProjectAgreement where ProjectAgreement_ID=(select max (ProjectAgreement_ID) from ProjectAgreement )").ToList().FirstOrDefault().ProjectAgreement_ID; //employeeRow.EmpId=employeeRow.EmpId != 0 ? employeeRow.EmpId : empModel.EmpId; } #region PA_PartnerNgo using (var tempContext = new SamajkalyanEntities()) { var deletelist = tempContext.PA_PartnerNgo.Where(x => x.ProjectAgreement_ID == model.ProjectAgreement_ID).ToList(); if (deletelist.Count > 0) { foreach (var item in deletelist) { if (model.PA_PartnerNgoViewModelList == null) { model.PA_PartnerNgoViewModelList = new List <PA_PatnerNgoViewModel>(); } var isExists = model.PA_PartnerNgoViewModelList.Where(x => x.PA_PatnerNGOs_ID == item.PA_PatnerNGOs_ID).FirstOrDefault(); if (isExists == null) { tempContext.PA_PartnerNgo.Remove(item); tempContext.SaveChanges(); } } } } if (model.PA_PartnerNgoViewModelList != null) { foreach (var item in model.PA_PartnerNgoViewModelList) { PA_PartnerNgo newRow = new PA_PartnerNgo(); newRow.ProjectAgreement_ID = model.ProjectAgreement_ID; newRow.Ngo_Name = item.Ngo_Name; newRow.Ngo_Number = item.Ngo_Number; newRow.PA_PatnerNGOs_ID = item.PA_PatnerNGOs_ID; newRow.Amount = item.Amount; //newRow.NoOfDep = item.NoOfDep; if (item.PA_PatnerNGOs_ID == 0) { ent.PA_PartnerNgo.Add(newRow); ent.SaveChanges(); } else { ent.PA_PartnerNgo.Attach(newRow); ent.Entry(newRow).State = EntityState.Modified; ent.SaveChanges(); } } } #endregion #region district using (var tempContext = new SamajkalyanEntities()) { var deletelist = tempContext.ProjectAgreement_Districts.Where(x => x.ProjectAgreementID == model.ProjectAgreement_ID).ToList(); if (deletelist.Count > 0) { foreach (var item in deletelist) { if (model.ProjectAgreement_DistrictsViewModelList == null) { model.ProjectAgreement_DistrictsViewModelList = new List <ProjectAgreement_DistrictsViewModel>(); } var isExists = model.ProjectAgreement_DistrictsViewModelList.Where(x => x.ProjectAgreementBudgetBreakDown_ID == item.ProjectAgreementBudgetBreakDown_ID).FirstOrDefault(); if (isExists == null) { tempContext.ProjectAgreement_Districts.Remove(item); tempContext.SaveChanges(); } } } } if (model.ProjectAgreement_DistrictsViewModelList != null) { foreach (var item in model.ProjectAgreement_DistrictsViewModelList) { ProjectAgreement_Districts newRow = new ProjectAgreement_Districts(); newRow.ProjectAgreementID = model.ProjectAgreement_ID; newRow.Locallevel = item.Locallevel; newRow.DistrictID = item.DistrictID; newRow.ProvienceId = item.ProvienceId; newRow.DistrictWiseAmmount = item.DistrictWiseAmmount; newRow.ProjectAgreementBudgetBreakDown_ID = item.ProjectAgreementBudgetBreakDown_ID; //newRow.NoOfDep = item.NoOfDep; if (item.ProjectAgreementBudgetBreakDown_ID == 0) { ent.ProjectAgreement_Districts.Add(newRow); ent.SaveChanges(); } else { ent.ProjectAgreement_Districts.Attach(newRow); ent.Entry(newRow).State = EntityState.Modified; ent.SaveChanges(); } } } #endregion } catch (Exception ex) { return(false); } } return(true); }
public bool InsertVehicleAuction(VehicleAuctionViewModel model) { using (SamajkalyanEntities ent = new SamajkalyanEntities()) { try { var workPermitRow = ent.VehicleAuctions.Where(x => x.VehicleAuctionId == model.VehicleAuctionId).FirstOrDefault(); if (workPermitRow == null) { workPermitRow = new VehicleAuction(); } ; workPermitRow.GA_ID = model.GA_ID; workPermitRow.PA_ID = model.PA_ID; workPermitRow.ApplicationRegistrationNumber = model.ApplicationRegistrationNumber; workPermitRow.VehicleNumber = model.VehicleNumber; workPermitRow.Type = model.Type; workPermitRow.VehicleNumber = model.VehicleNumber; workPermitRow.SummaryOfDecision = model.SummaryOfDecision; workPermitRow.RegistrationDate = model.RegistrationDate; workPermitRow.RegistrationDatep = model.RegistrationDatep; workPermitRow.VehicleType = model.VehicleType; workPermitRow.Remarks = model.Remarks; workPermitRow.CreatedBy = model.CreatedBy; workPermitRow.CreatedDate = model.CreatedDate; if (model.VehicleAuctionId == 0) { ent.VehicleAuctions.Add(workPermitRow); ent.SaveChanges(); } else { workPermitRow.UpdatedBy = model.UpdatedBy; workPermitRow.UpdateDate = model.UpdateDate; ent.VehicleAuctions.Attach(workPermitRow); ent.Entry(workPermitRow).State = EntityState.Modified; ent.SaveChanges(); } //if (model.ImportId <= 0) //{ // model.ImportId = ent.Database.SqlQuery<WorkPermitViewModel>("select * from WorkPermit where WorkPermitId=(select max (WorkPermitId) from WorkPermit )").ToList().FirstOrDefault().WorkPermitId; // //employeeRow.EmpId=employeeRow.EmpId != 0 ? employeeRow.EmpId : empModel.EmpId; //} } catch (Exception ex) { return(false); } } return(true); }
public bool Insert(IngoRenewalViewModel model) { using (SamajkalyanEntities ent = new SamajkalyanEntities()) { try { var Row = ent.IngoRenewals.Where(x => x.RenewalId == model.RenewalId).FirstOrDefault(); //_context.Database.Connection.Open(); //_context.Database.Connection.BeginTransaction(); if (Row == null) { Row = new IngoRenewal(); } ; Row.RenewDate = model.RenewDate; Row.Period = model.Period; Row.IngoId = model.IngoId; Row.RenewCharge = model.RenewCharge; Row.FileLocation = model.FileLocation; Row.RenewalDateNP = model.RenewalDateNP; //deploymentRow.Status = true; if (model.RenewalId == 0) { // generalAgreementRow.Status = false; Row.CreatedDate = model.CreatedDate; Row.CreatedBy = model.CreatedBy; ent.IngoRenewals.Add(Row); ent.SaveChanges(); } else { // deploymentRow.Status = dmodel.Status ?? false; Row.UpdatedBy = model.UpdatedBy; Row.UpdatedDate = model.UpdatedDate; ent.IngoRenewals.Attach(Row); ent.Entry(Row).State = EntityState.Modified; ent.SaveChanges(); } //if (model.TerminationId <= 0) //{ // model.GeneralAgreement_ID = ent.Database.SqlQuery<GeneralAgreementViewModel>("select * from GeneralAgreement where GeneralAgreement_ID=(select max (GeneralAgreement_ID) from GeneralAgreement )").ToList().FirstOrDefault().GeneralAgreement_ID; // //employeeRow.EmpId=employeeRow.EmpId != 0 ? employeeRow.EmpId : empModel.EmpId; //} if (model.RenewalId == 0) { model.RenewalId = ent.IngoRenewals.Max(x => x.RenewalId); } #region document using (var tempContext = new SamajkalyanEntities()) { var deletelist = tempContext.IngoRewnewalDocuments.Where(x => x.RewnewalId == model.RenewalId).ToList(); if (deletelist.Count > 0) { foreach (var item in deletelist) { if (model.IngoRewnewalDocumentViewModelList == null) { model.IngoRewnewalDocumentViewModelList = new List <IngoRewnewalDocumentViewModel>(); } var isExists = model.IngoRewnewalDocumentViewModelList.Where(x => x.DocumentId == item.DocumentId).FirstOrDefault(); if (isExists == null) { try { System.IO.File.Delete(HttpContext.Current.Server.MapPath(@"~" + item.DocumentLocation)); } catch (Exception) { //throw; } tempContext.IngoRewnewalDocuments.Remove(item); tempContext.SaveChanges(); } } } } if (model.IngoRewnewalDocumentViewModelList != null) { foreach (var item in model.IngoRewnewalDocumentViewModelList) { IngoRewnewalDocument newRow = new IngoRewnewalDocument(); newRow.DocumentId = item.DocumentId; newRow.RewnewalId = model.RenewalId; newRow.DocumentLocation = item.DocumentLocation; newRow.FileName = item.DocumentName; if (item.DocumentId == 0) { ent.IngoRewnewalDocuments.Add(newRow); ent.SaveChanges(); } else { ent.IngoRewnewalDocuments.Attach(newRow); ent.Entry(newRow).State = EntityState.Modified; ent.SaveChanges(); } } } #endregion } catch (Exception ex) { return(false); } } return(true); }