public OBKContractViewModel SaveContract2(Guid guid, OBKContractViewModel contractViewModel) { var ret = new OBKContractViewModel(); var obkContract = AppContext.OBK_Contract.Where(o => o.Id == contractViewModel.Id).FirstOrDefault(); if (obkContract != null) { FillContract(contractViewModel, obkContract); ret.Id = contractViewModel.Id; } else { OBK_Contract contract = new OBK_Contract(); contract.Id = guid; contract.CreatedDate = DateTime.Now; contract.Number = "б/н"; contract.Status = 1; var employeeId = UserHelper.GetCurrentEmployee().Id; contract.EmployeeId = employeeId; FillContract(contractViewModel, contract); AppContext.OBK_Contract.Add(contract); AppContext.SaveChanges(); ret.Id = contract.Id; } return(ret); }
private void FillContract(OBKContractViewModel contractViewModel, OBK_Contract obkContract) { obkContract.Type = contractViewModel.Type != 0 ? contractViewModel.Type : 1; if (obkContract.DeclarantContactId != null) { var contactData = AppContext.OBK_DeclarantContact.Where(x => x.Id == obkContract.DeclarantContactId).FirstOrDefault(); FillContactData(contractViewModel, contactData, obkContract); AppContext.SaveChanges(); } else { OBK_DeclarantContact contactData = new OBK_DeclarantContact(); contactData.Id = Guid.NewGuid(); contactData.CreateDate = DateTime.Now; contactData.IsHasBossDocNumber = false; contactData.IsHasSignDocNumber = false; contactData.SignType = false; AppContext.OBK_DeclarantContact.Add(contactData); AppContext.SaveChanges(); obkContract.DeclarantContactId = contactData.Id; } AppContext.SaveChanges(); }
private void FillContactData(OBKContractViewModel contractViewModel, OBK_DeclarantContact contactData, OBK_Contract obkContract) { contactData.AddressLegalRu = contractViewModel.AddressLegalRu; contactData.AddressLegalKz = contractViewModel.AddressLegalKz; contactData.AddressFact = contractViewModel.AddressFact; contactData.Phone = contractViewModel.Phone; contactData.Email = contractViewModel.Email; contactData.BossLastName = contractViewModel.BossLastName; contactData.BossFirstName = contractViewModel.BossFirstName; contactData.BossMiddleName = contractViewModel.BossMiddleName; contactData.BossPosition = contractViewModel.BossPosition; contactData.BossPositionKz = contractViewModel.BossPositionKz; contactData.BossDocType = contractViewModel.BossDocType; contactData.IsHasBossDocNumber = contractViewModel.IsHasBossDocNumber; contactData.BossDocNumber = contractViewModel.BossDocNumber; contactData.BossDocCreatedDate = contractViewModel.BossDocCreatedDate; contactData.BossDocEndDate = contractViewModel.BossDocEndDate; contactData.BossDocUnlimited = contractViewModel.BossDocUnlimited; contactData.SignerIsBoss = contractViewModel.SignerIsBoss; contactData.SignLastName = contractViewModel.SignLastName; contactData.SignFirstName = contractViewModel.SignFirstName; contactData.SignMiddleName = contractViewModel.SignMiddleName; contactData.SignPosition = contractViewModel.SignPosition; contactData.SignPositionKz = contractViewModel.SignPositionKz; contactData.SignDocType = contractViewModel.SignDocType; contactData.IsHasSignDocNumber = contractViewModel.IsHasSignDocNumber; contactData.SignDocNumber = contractViewModel.SignDocNumber; contactData.SignDocCreatedDate = contractViewModel.SignDocCreatedDate; contactData.SignDocEndDate = contractViewModel.SignDocEndDate; contactData.SignDocUnlimited = contractViewModel.SignDocUnlimited; contactData.BankIik = contractViewModel.BankIik; contactData.BankBik = contractViewModel.BankBik; contactData.CurrencyId = contractViewModel.CurrencyId; contactData.BankNameRu = contractViewModel.BankNameRu; contactData.BankNameKz = contractViewModel.BankNameKz; contactData.DeclarantId = obkContract.DeclarantId; }
//public OBKContractViewModel SaveContract(OBKContractViewModel contractViewModel) //{ // OBK_Contract projectContract = AppContext.OBK_Contract.FirstOrDefault(o => o.Id == contractViewModel.Id); // if (projectContract != null) // { // UpdateFields(contractViewModel, projectContract); // AppContext.SaveChanges(); // } // else // { // OBK_Contract newContract = new OBK_Contract(); // newContract.Id = Guid.NewGuid(); // newContract.CreatedDate = DateTime.Now; // newContract.Number = "б/н"; // newContract.Status = 1; // AppContext.OBK_Contract.Add(newContract); // AppContext.SaveChanges(); // } //} private void UpdateFields(OBKContractViewModel viewModel, OBK_Contract model) { //model.Type = viewModel.Type; //model.dec }
public OBKContractViewModel LoadContract(Guid id) { var OBKContract = AppContext.OBK_Contract.Where(x => x.Id == id).FirstOrDefault(); OBKContractViewModel contractViewModel = new OBKContractViewModel(); contractViewModel.Id = OBKContract.Id; contractViewModel.Type = OBKContract.Type; //if (OBKContract.DeclarantId != null) //{ // if (OBKContract.OBK_Declarant.IsConfirmed) // { // contractViewModel.DeclarantId = OBKContract.DeclarantId; // } // else // { // contractViewModel.DeclarantId = Guid.Empty; // } // contractViewModel.DeclarantIsResident = OBKContract.OBK_Declarant.IsResident; // contractViewModel.DeclarantOrganizationFormId = OBKContract.OBK_Declarant.OrganizationFormId; // contractViewModel.DeclarantBin = OBKContract.OBK_Declarant.Bin; // contractViewModel.DeclarantNameKz = OBKContract.OBK_Declarant.NameKz; // contractViewModel.DeclarantNameRu = OBKContract.OBK_Declarant.NameRu; // contractViewModel.DeclarantNameEn = OBKContract.OBK_Declarant.NameEn; // contractViewModel.DeclarantCountryId = OBKContract.OBK_Declarant.CountryId; //} if (OBKContract.DeclarantContactId != null) { contractViewModel.AddressLegalRu = OBKContract.OBK_DeclarantContact.AddressLegalRu; contractViewModel.AddressLegalKz = OBKContract.OBK_DeclarantContact.AddressLegalKz; contractViewModel.AddressFact = OBKContract.OBK_DeclarantContact.AddressFact; contractViewModel.Phone = OBKContract.OBK_DeclarantContact.Phone; contractViewModel.Email = OBKContract.OBK_DeclarantContact.Email; contractViewModel.BossLastName = OBKContract.OBK_DeclarantContact.BossLastName; contractViewModel.BossFirstName = OBKContract.OBK_DeclarantContact.BossFirstName; contractViewModel.BossMiddleName = OBKContract.OBK_DeclarantContact.BossMiddleName; contractViewModel.BossPosition = OBKContract.OBK_DeclarantContact.BossPosition; contractViewModel.BossPositionKz = OBKContract.OBK_DeclarantContact.BossPositionKz; contractViewModel.BossDocType = OBKContract.OBK_DeclarantContact.BossDocType; contractViewModel.IsHasBossDocNumber = OBKContract.OBK_DeclarantContact.IsHasBossDocNumber; contractViewModel.BossDocNumber = OBKContract.OBK_DeclarantContact.BossDocNumber; contractViewModel.BossDocCreatedDate = OBKContract.OBK_DeclarantContact.BossDocCreatedDate; contractViewModel.BossDocEndDate = OBKContract.OBK_DeclarantContact.BossDocEndDate; contractViewModel.BossDocUnlimited = OBKContract.OBK_DeclarantContact.BossDocUnlimited; contractViewModel.SignerIsBoss = OBKContract.OBK_DeclarantContact.SignerIsBoss; contractViewModel.SignLastName = OBKContract.OBK_DeclarantContact.SignLastName; contractViewModel.SignFirstName = OBKContract.OBK_DeclarantContact.SignFirstName; contractViewModel.SignMiddleName = OBKContract.OBK_DeclarantContact.SignMiddleName; contractViewModel.SignPosition = OBKContract.OBK_DeclarantContact.SignPosition; contractViewModel.SignPositionKz = OBKContract.OBK_DeclarantContact.SignPositionKz; contractViewModel.SignDocType = OBKContract.OBK_DeclarantContact.SignDocType; contractViewModel.IsHasSignDocNumber = OBKContract.OBK_DeclarantContact.IsHasSignDocNumber; contractViewModel.SignDocNumber = OBKContract.OBK_DeclarantContact.SignDocNumber; contractViewModel.SignDocCreatedDate = OBKContract.OBK_DeclarantContact.SignDocCreatedDate; contractViewModel.SignDocEndDate = OBKContract.OBK_DeclarantContact.SignDocEndDate; contractViewModel.SignDocUnlimited = OBKContract.OBK_DeclarantContact.SignDocUnlimited; contractViewModel.BankIik = OBKContract.OBK_DeclarantContact.BankIik; contractViewModel.BankBik = OBKContract.OBK_DeclarantContact.BankBik; contractViewModel.CurrencyId = OBKContract.OBK_DeclarantContact.CurrencyId; contractViewModel.BankNameRu = OBKContract.OBK_DeclarantContact.BankNameRu; contractViewModel.BankNameKz = OBKContract.OBK_DeclarantContact.BankNameKz; } return(contractViewModel); }
public ActionResult ContractSave(Guid Guid, OBKContractViewModel contractViewModel) { OBKContractViewModel savedContract = obkRepo.SaveContract2(Guid, contractViewModel); return(Json(savedContract)); }
public ActionResult LoadContract(Guid id) { OBKContractViewModel contract = obkRepo.LoadContract(id); return(Json(contract, JsonRequestBehavior.AllowGet)); }
public ActionResult ContractAdditionSave(Guid Guid, OBKContractViewModel contractViewModel, OBKContractAdditionViewModel contractAddition) { OBKContractAdditionViewModel contractAdditionVideModel = obkRepo.SaveContractAddition(Guid, contractViewModel, contractAddition); return(Json(contractAdditionVideModel)); }
public OBKContractAddition(OBKContractViewModel contract, OBKContractAdditionViewModel contractAddition) { Contract = contract; ContractAddition = contractAddition; }