public void NUnit_Contract_Domain_Edit() { Hre_ContractServices service = new Hre_ContractServices(); var model = new Hre_Contract { Id = 5, Code = "Update Code Test", ProfileID = 1, ContractNo = "Update No ", ContractTypeID = 1, DateSigned = DateTime.Parse("2014/06/05"), DateStart = DateTime.Parse("2014/08/07") }; string result = service.Edit(model); if (result != string.Empty) { Console.WriteLine("Process Success >>> Update >>> " + model.Id + " | " + model.Code + " | " + model.ProfileID + " | " + model.ContractNo + " | " + model.ContractTypeID + " | " + model.DateSigned + " | " + model.DateStart ); } }
public Hre_ContractModel Put([Bind] Hre_ContractModel model) { var ContractServices = new Hre_ContractServices(); string status = string.Empty; string id = string.Empty; foreach (var item in model.selecteIds) { id += Common.DotNetToOracle(item.ToString()) + ","; } id = id.Substring(0, id.Length - 1); string type = model.Status; var service = new BaseService(); var actionServices = new ActionService(UserLogin); if (model.ID == Guid.Empty) { model.DateExtend = model.DateEnd; } var objContract = new List <object>(); objContract.AddRange(new object[2]); objContract[0] = 1; objContract[1] = int.MaxValue - 1; var lstContracts = actionServices.GetData <Hre_ContractEntity>(objContract, ConstantSql.hrm_hr_sp_get_ContractData, ref status).ToList(); if (!string.IsNullOrEmpty(id)) { try { var idItem = id.Split(','); for (int i = 0; i < idItem.Count(); i++) { var idInt = idItem[i]; if (idInt != null) { var entity = lstContracts.Where(s => s.ID != null && Common.DotNetToOracle(s.ID.ToString()) == idInt).FirstOrDefault(); var lstContractByProfileID = lstContracts.Where(s => s.ProfileID == entity.ProfileID && s.Status == EnumDropDown.Status.E_APPROVED.ToString()).ToList(); var listIdContract = string.Empty; if (lstContractByProfileID.Count > 0) { listIdContract = string.Join(",", lstContractByProfileID.Select(d => d.ContractTypeID)); } entity = ContractServices.SetNewCodeContract(entity, listIdContract, UserLogin); entity.Status = type; if (!string.IsNullOrEmpty(entity.ContractNo)) { // Theo task 0049504 - chỉ edit lại cột TimesContract nếu hd loại có thời hạn if (entity.ContractTypeID != null) { var contracttypeBycontract = actionServices.GetData <Cat_ContractTypeEntity>(Common.DotNetToOracle(entity.ContractTypeID.ToString()), ConstantSql.hrm_cat_sp_get_ContractTypeById, ref status).FirstOrDefault(); if (contracttypeBycontract != null && contracttypeBycontract.Type == HRM.Infrastructure.Utilities.EnumDropDown.TypeContract.E_DURATION.ToString()) { try { string times = entity.ContractNo.Substring(entity.ContractNo.Length - 1, 1); int Year = int.Parse(times); entity.TimesContract = Year; } catch { } } } } status = ContractServices.Edit(entity); model.SetPropertyValue(Constant.ActionStatus, status); } } } catch (Exception ex) { model.SetPropertyValue(Constant.ActionStatus, NotificationType.Error.ToString() + "," + ex.Message); } } return(model); }