public GeneralAgreementViewModel GetGAByID(int?id) { SamajkalyanEntities ent = new SamajkalyanEntities(); GeneralAgreementViewModel entity = ent.GeneralAgreements.Where(x => x.GeneralAgreement_ID == id).Select(x => new GeneralAgreementViewModel() { GeneralAgreement_ID = x.GeneralAgreement_ID, Name_Of_Ingo = x.Name_Of_Ingo, Name_of_Ingo_Nepali = x.Name_of_Ingo_Nepali, Ga_Date = x.Ga_Date, Ga_Date_Nepali = x.Ga_Date_Nepali, Period = x.Period, Pre_Annum_Commitment_Amount = x.Pre_Annum_Commitment_Amount, Ga_Service_Charge = x.Ga_Service_Charge, Sector = x.Sector, Hq_Address = x.Hq_Address, Contact_Person = x.Contact_Person, Country_Official_Nepal_Address = x.Country_Official_Nepal_Address, Contact_Number = x.Contact_Number, Email = x.Email, GA_TerminationDate = x.GA_TerminationDate, Ga_TerminationDate_Nepali = x.Ga_TerminationDate_Nepali, PA_Attachment_Location = x.PA_Attachment_Location, Scan_GA_Location = x.Scan_GA_Location, Country = x.Country, DeletedBy = x.DeletedBy, UpdatedBy = x.UpdatedBy, UpdatedDate = x.UpdatedDate, CreatedDate = DateTime.Now, }).FirstOrDefault(); return(entity); }
public static List <provincesVDCDetail> GetVdcListByDistrictId(int districtId) { using (var _context = new SamajkalyanEntities()) { return(_context.provincesVDCDetails.Where(x => x.ProvincesDistrictId == districtId).ToList()); } }
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 static IEnumerable <SelectListItem> GetProvience() { using (var _ct = new SamajkalyanEntities()) { return(new SelectList(_ct.provincesSetups.Where(x => x.Status == 1).ToList(), "provincesId", "provincesName")); } }
public static List <ProvincesDistrictSetup> GetDistrictListByProvinceId(int provinceId) { using (var _context = new SamajkalyanEntities()) { return(_context.ProvincesDistrictSetups.Where(x => x.ProvincesId == provinceId).ToList()); } }
public GeneralAgreement GetGAByID(int?id) { SamajkalyanEntities ent = new SamajkalyanEntities(); GeneralAgreement entity = ent.GeneralAgreements.Where(x => x.GeneralAgreement_ID == id).FirstOrDefault(); return(entity); }
public static IEnumerable <SelectListItem> GetWorkPermitTypelist() { using (var _ct = new SamajkalyanEntities()) { return(new SelectList(_ct.WorKPermitTypes.Where(x => x.DeletedDate == null).ToList(), "WorkPermitTypeId", "Name")); } }
public List <ProjectAgreementViewModel> GetPAList() { SamajkalyanEntities ent = new SamajkalyanEntities(); List <ProjectAgreementViewModel> GaList = ent.ProjectAgreements.Select(x => new ProjectAgreementViewModel() { GeneralAgreement_ID = x.GeneralAgreement_ID, ProjectAgreement_ID = x.ProjectAgreement_ID, IngoName = x.GeneralAgreement.Name_of_Ingo_Nepali, Name_Of_Project = x.Name_Of_Project, Name_Of_Project_Nepali = x.Name_Of_Project_Nepali, Name_Of_Bank = x.Name_Of_Bank, PA_Sign_Date = x.PA_Sign_Date, Project_Period = x.Project_Period, Total_Budget = x.Total_Budget, Admin_Cost = x.Admin_Cost, Program_Cost = x.Program_Cost, Account_NO = x.Account_NO, Doner = x.Doner, No_Of_Expertriate = x.No_Of_Expertriate, Pa_Sign_DateNepali = x.Pa_Sign_DateNepali, DeletedBy = x.DeletedBy, UpDatedBy = x.UpDatedBy, UpDatedDaye = x.UpDatedDaye, DeletedDate = x.DeletedDate, CreatedDate = DateTime.Now, }).Where(x => x.DeletedDate == null).ToList(); return(GaList); }
public static IEnumerable <SelectListItem> GetIngoName() { using (var _ct = new SamajkalyanEntities()) { return(new SelectList(_ct.GeneralAgreements.Where(x => x.DeletdedDate == null).ToList(), "GeneralAgreement_ID", "Name_of_Ingo_Nepali")); } }
public static string districtName(int id) { using (var _context = new SamajkalyanEntities()) { var jpt = _context.ProvincesDistrictSetups.Where(x => x.ProvincesDistrictId == id).FirstOrDefault().DistrictName; return(jpt); } }
public static string proviencceName(int id) { using (var _context = new SamajkalyanEntities()) { var jpt = _context.provincesSetups.Where(x => x.provincesId == id).FirstOrDefault().provincesName; return(jpt); } }
public static string localName(int id) { using (var _context = new SamajkalyanEntities()) { var jpt = _context.provincesVDCDetails.Where(x => x.ProvincesVDCDetailsID == id).FirstOrDefault().VDCName; return(jpt); } }
public ProjectAgreementViewModel GetPAByID(int?id) { SamajkalyanEntities ent = new SamajkalyanEntities(); ProjectAgreementViewModel entity = ent.ProjectAgreements.Where(x => x.ProjectAgreement_ID == id).Select(x => new ProjectAgreementViewModel() { GeneralAgreement_ID = x.GeneralAgreement_ID, ProjectAgreement_ID = x.ProjectAgreement_ID, Name_Of_Project = x.Name_Of_Project, Name_Of_Project_Nepali = x.Name_Of_Project_Nepali, Name_Of_Bank = x.Name_Of_Bank, PA_Sign_Date = x.PA_Sign_Date, Project_Period = x.Project_Period, Total_Budget = x.Total_Budget, Admin_Cost = x.Admin_Cost, Program_Cost = x.Program_Cost, Account_NO = x.Account_NO, Doner = x.Doner, No_Of_Expertriate = x.No_Of_Expertriate, IngoName = x.GeneralAgreement.Name_of_Ingo_Nepali, Pa_Sign_DateNepali = x.Pa_Sign_DateNepali, DeletedBy = x.DeletedBy, UpDatedBy = x.UpDatedBy, UpDatedDaye = x.UpDatedDaye, CreatedDate = DateTime.Now, }).FirstOrDefault(); entity.PA_PartnerNgoViewModelList = ent.PA_PartnerNgo.Where(x => x.ProjectAgreement_ID == id).Select(x => new PA_PatnerNgoViewModel() { ProjectAgreement_ID = x.ProjectAgreement_ID, Ngo_Number = x.Ngo_Number, Amount = x.Amount, PA_PatnerNGOs_ID = x.PA_PatnerNGOs_ID, Ngo_Name = x.Ngo_Name, }).ToList(); entity.ProjectAgreement_DistrictsViewModelList = ent.ProjectAgreement_Districts.Where(x => x.ProjectAgreementID == id).Select(x => new ProjectAgreement_DistrictsViewModel() { ProjectAgreementBudgetBreakDown_ID = x.ProjectAgreementBudgetBreakDown_ID, DistrictID = x.DistrictID, Locallevel = x.Locallevel, ProvienceId = x.ProvienceId, DistrictWiseAmmount = x.DistrictWiseAmmount, ProjectAgreementID = x.ProjectAgreementID, }).ToList(); if (entity.ProjectAgreement_DistrictsViewModelList.Count() > 0) { foreach (var item in entity.ProjectAgreement_DistrictsViewModelList) { item.ProvienceName = ent.provincesSetups.Where(x => x.provincesId == item.ProvienceId).FirstOrDefault().provincesName; item.DistrictName = ent.ProvincesDistrictSetups.Where(x => x.ProvincesDistrictId == item.DistrictID).FirstOrDefault().DistrictName; item.locallevelName = ent.provincesVDCDetails.Where(x => x.ProvincesVDCDetailsID == item.Locallevel).FirstOrDefault().VDCName; } } return(entity); }
public static string GetGeneralAgremenetDate(int id) { using (var _context = new SamajkalyanEntities()) { DateTime?jpt = _context.GeneralAgreements.Where(x => x.GeneralAgreement_ID == id).FirstOrDefault().Ga_Date; string a = jpt.HasValue ? jpt.Value.ToString("yyyy-MM-dd") : "[N/A]"; return(a); } }
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 static int GetGeneralAgremenetPaCount(int id, int?pid) { using (var _context = new SamajkalyanEntities()) { int jpt = _context.ProjectAgreements.Where(x => x.GeneralAgreement_ID == id && x.ProjectAgreement_ID != pid).Count(); //int jpt2 = _context.ProjectAgreements.Where(x => x.ProjectAgreement_ID == pid).Count(); // int dif = jpt - jpt2; return(jpt); } }
public static IEnumerable <SelectListItem> GetMunVdc(int?id) { using (var _ct = new SamajkalyanEntities()) { if (id == null) { return(new SelectList(_ct.provincesVDCDetails.ToList(), "ProvincesVDCDetailsID", "VDCName")); } else { return(new SelectList(_ct.provincesVDCDetails.Where(x => x.ProvincesDistrictId == id).ToList(), "ProvincesVDCDetailsID", "VDCName")); } } }
public List <IngoRewnewalDocumentViewModel> getDocumentList(int id) { SamajkalyanEntities ent = new SamajkalyanEntities(); var jpt = ent.IngoRewnewalDocuments.Where(x => x.RewnewalId == id).Select(x => new IngoRewnewalDocumentViewModel() { DocumentId = x.DocumentId, DocumentLocation = x.DocumentLocation, RewnewalId = x.RewnewalId, DocumentName = x.FileName }).ToList(); return(jpt); }
public static IEnumerable <SelectListItem> Getpalist(int?id) { using (var _ct = new SamajkalyanEntities()) { if (id == null) { return(new SelectList(_ct.ProjectAgreements.Where(x => x.DeletedDate == null).ToList(), "ProjectAgreement_ID", "Name_Of_Project_Nepali")); } else { return(new SelectList(_ct.ProjectAgreements.Where(x => x.DeletedDate == null && x.GeneralAgreement_ID == id).ToList(), "ProjectAgreement_ID", "Name_Of_Project_Nepali")); } } }
public static IEnumerable <SelectListItem> GetDistrict(int?id) { using (var _ct = new SamajkalyanEntities()) { if (id == null) { return(new SelectList(_ct.ProvincesDistrictSetups.ToList(), "ProvincesDistrictId", "DistrictName")); } else { return(new SelectList(_ct.ProvincesDistrictSetups.Where(x => x.ProvincesId == id).ToList(), "ProvincesDistrictId", "DistrictName")); } } }
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 List <IngoTerminationViewModel> GetIngoTerminationList() { SamajkalyanEntities ent = new SamajkalyanEntities(); List <IngoTerminationViewModel> List = ent.IngoTerminations.Select(x => new IngoTerminationViewModel() { NameOfAssest = x.NameOfAssest, IngoId = x.IngoId, TerminationId = x.TerminationId, TerminationDate = x.TerminationDate, TerminationDateNp = x.TerminationDateNp, EvaluationOfReportAttached = x.EvaluationOfReportAttached, IngoName = x.GeneralAgreement.Name_of_Ingo_Nepali, DeletdDate = x.DeletdDate, DeletedBy = x.DeletedBy, }).Where(x => x.DeletdDate == null).ToList(); //}).Where(x => x.DeletedDate == null).ToList(); return(List); }
public IngoTerminationViewModel GetIngoTerminationById(int id) { SamajkalyanEntities ent = new SamajkalyanEntities(); IngoTerminationViewModel List = ent.IngoTerminations.Select(x => new IngoTerminationViewModel() { NameOfAssest = x.NameOfAssest, IngoId = x.IngoId, TerminationId = x.TerminationId, TerminationDate = x.TerminationDate, TerminationDateNp = x.TerminationDateNp, EvaluationOfReportAttached = x.EvaluationOfReportAttached, IngoName = x.GeneralAgreement.Name_Of_Ingo, DeletdDate = x.UpdateDate, DeletedBy = x.DeletedBy, }).Where(x => x.TerminationId == id).FirstOrDefault(); //}).Where(x => x.DeletedDate == null).ToList(); return(List); }
public List <IngoRenewalViewModel> GetIngoRenewalList() { SamajkalyanEntities ent = new SamajkalyanEntities(); List <IngoRenewalViewModel> List = ent.IngoRenewals.Select(x => new IngoRenewalViewModel() { RenewDate = x.RenewDate, Period = x.Period, IngoId = x.IngoId, RenewCharge = x.RenewCharge, RenewalId = x.RenewalId, RenewalDateNP = x.RenewalDateNP, Ingoname = x.GeneralAgreement.Name_of_Ingo_Nepali, DeletetDate = x.DeletetDate, DeletedBy = x.DeletedBy, }).Where(x => x.DeletetDate == null).ToList(); //}).Where(x => x.DeletedDate == null).ToList(); return(List); }
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 IngoRenewalViewModel GetIIngoRenewalById(int id) { SamajkalyanEntities ent = new SamajkalyanEntities(); IngoRenewalViewModel List = ent.IngoRenewals.Select(x => new IngoRenewalViewModel() { RenewDate = x.RenewDate, Period = x.Period, IngoId = x.IngoId, RenewCharge = x.RenewCharge, RenewalId = x.RenewalId, Ingoname = x.GeneralAgreement.Name_of_Ingo_Nepali, FileLocation = x.FileLocation, RenewalDateNP = x.RenewalDateNP, DeletetDate = x.DeletetDate, DeletedBy = x.DeletedBy, }).Where(x => x.RenewalId == id).FirstOrDefault(); //}).Where(x => x.DeletedDate == null).ToList(); return(List); }
public PrincipaleConstantOfVolunteerViewModel GetPCVByID(int?id) { SamajkalyanEntities ent = new SamajkalyanEntities(); PrincipaleConstantOfVolunteerViewModel entity = ent.PrincipaleConstantOfVolunters.Where(x => x.VolunteerID == id).Select(x => new PrincipaleConstantOfVolunteerViewModel() { VolunteerID = x.VolunteerID, GA_Id = x.GA_Id, PAName = x.ProjectAgreement.Name_Of_Project_Nepali, PA_Id = x.PA_Id, Council_sRagistrationNumber = x.Council_sRagistrationNumber, C_Council_sRagistrationDate = x.C_Council_sRagistrationDate, C_Council_sRagistrationDateNp = x.C_Council_sRagistrationDateNp, NameOfAppicant = x.NameOfAppicant, Country = x.Country, PassportNumber = x.PassportNumber, VisaDuration = x.VisaDuration, ApplicationDesingation = x.ApplicationDesingation, ApplicationSector = x.ApplicationSector, Agreement = x.Agreement, ServiceReciverNGOSName = x.ServiceReciverNGOSName, DecisionDate = x.DecisionDate, DecisionDateNp = x.DecisionDateNp, Remarks = x.Remarks, DeletedDate = x.DeletedDate, // Country = x.Country, DeletedBy = x.DeletedBy, UpdatedBy = x.UpdatedBy, UpdateDate = x.UpdateDate, CreatedDate = x.DecisionDate, CreateedBy = x.CreateedBy }).FirstOrDefault(); entity.GAName = ent.GeneralAgreements.Where(x => x.GeneralAgreement_ID == entity.GA_Id).FirstOrDefault().Name_of_Ingo_Nepali; return(entity); }
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 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); }