public async Task <IActionResult> Create_Or_Update(ImportReceipt inputModel) { try { if (inputModel.Id == 0) { var session = _httpContextAccessor.HttpContext.Session; var account = Portal.Utils.SessionExtensions.Get <Accounts>(session, Portal.Utils.SessionExtensions.SessionAccount); inputModel.CreatedBy = account.Id; inputModel.CreatedDate = DateTime.Now; await _importReceiptManager.Create(inputModel); return(Json(new { Result = true, Message = "Thêm mới dữ liệu thành công" })); } else { //await _importReceiptManager.Update(inputModel); return(Json(new { Result = true, Message = "Cập nhật dữ liệu thành công" })); } } catch (Exception ex) { return(Json(new { Result = false, Message = ex.Message })); } }
internal static void RemoveMemory(ImportReceipt objectValue) { if (DicImportReceipt.ContainsKey(objectValue.Id)) { DicImportReceipt.Remove(objectValue.Id); } }
public static bool ValidateUpdate(ImportReceipt obj, out string errorCode, out string errorMess) { errorCode = null; errorMess = null; try { if (obj == null) { errorCode = ErrorCodeEnum.DataInputWrong.ToString(); return(false); } if (obj.IdProvider == null) { errorCode = ErrorCodeEnum.DataInputWrong.ToString(); errorMess = "IdProvider not allow null value"; return(false); } if (obj.ImportDate == null) { errorCode = ErrorCodeEnum.DataInputWrong.ToString(); errorMess = "ImportDate not allow null value"; return(false); } } catch (Exception ex) { Logger.Write(ex.ToString()); throw; } return(true); }
public static List <string> GetListEntityNameInit() { return(new List <string> { Area.EntityName(), Connection.EntityName(), ConnectionStatus.EntityName(), ConnectionType.EntityName(), Contract.EntityName(), Customer.EntityName(), CustomerFeedback.EntityName(), DetailImportReceipt.EntityName(), Device.EntityName(), DeviceType.EntityName(), Employee.EntityName(), Fee.EntityName(), Image.EntityName(), ImportReceipt.EntityName(), Manufacturer.EntityName(), Payment.EntityName(), PaymentFee.EntityName(), Provider.EntityName(), ServiceForm.EntityName(), ServiceFormStatus.EntityName(), ServicePack.EntityName(), ServicePackFee.EntityName(), Store.EntityName(), }); }
public ImportReceiptRes(ImportReceipt entity, List <DetailImportReceipt> listDetailImportReceipt) { ListDetailImportReceipt = listDetailImportReceipt; IdProvider = entity.IdProvider; ImportDate = entity.ImportDate; TotalPrice = entity.TotalPrice; CreatedAt = entity.CreatedAt; CreatedBy = entity.CreatedBy; Id = entity.Id; IsDeleted = entity.IsDeleted; UpdatedAt = entity.UpdatedAt; UpdatedBy = entity.UpdatedBy; }
public override List <BaseEntity> PopulateBusinessObjectFromReader(IDataReader dataReader) { var list = new List <BaseEntity>(); _dicIndex = new Dictionary <string, int>(); while (dataReader.Read()) { var businessObject = new ImportReceipt(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); }
internal static void SetMemory(ImportReceipt objectValue) { string entityName = objectValue.GetName(); // chua co thi khoi tao if (!DicMaxKeyEntity.ContainsKey(entityName)) { DicMaxKeyEntity[entityName] = 0; } // co roi thi so sanh roi set max key vao dic if (DicMaxKeyEntity[entityName] < objectValue.Id) { DicMaxKeyEntity[entityName] = objectValue.Id; } DicImportReceipt[objectValue.Id] = objectValue; }
public async Task Create(ImportReceipt inputModel) { try { await _unitOfWork.ImportReceiptRepository.Add(inputModel); if (inputModel.listAccessory != null) { await CreateImport_Accesory(inputModel.listAccessory, inputModel); } await _unitOfWork.SaveChange(); } catch (Exception ex) { throw ex; } }
internal void PopulateBusinessObjectFromReader(ImportReceipt businessObject, IDataReader dataReader) { if (_dicIndex.Count == 0) { FillDicIndex(dataReader); } if (GetIndex(ImportReceipt.ImportReceiptFields.CreatedAt.ToString()) != -1) { if (!dataReader.IsDBNull(GetIndex(ImportReceipt.ImportReceiptFields.CreatedAt.ToString()))) { businessObject.CreatedAt = dataReader.GetDateTime(GetIndex(ImportReceipt.ImportReceiptFields.CreatedAt.ToString())); } } if (GetIndex(ImportReceipt.ImportReceiptFields.CreatedBy.ToString()) != -1) { if (!dataReader.IsDBNull(GetIndex(ImportReceipt.ImportReceiptFields.CreatedBy.ToString()))) { businessObject.CreatedBy = dataReader.GetInt32(GetIndex(ImportReceipt.ImportReceiptFields.CreatedBy.ToString())); } } businessObject.Id = dataReader.GetInt32(GetIndex(ImportReceipt.ImportReceiptFields.Id.ToString())); if (GetIndex(ImportReceipt.ImportReceiptFields.IdProvider.ToString()) != -1) { businessObject.IdProvider = dataReader.GetInt32(GetIndex(ImportReceipt.ImportReceiptFields.IdProvider.ToString())); } if (GetIndex(ImportReceipt.ImportReceiptFields.ImportDate.ToString()) != -1) { businessObject.ImportDate = dataReader.GetDateTime(GetIndex(ImportReceipt.ImportReceiptFields.ImportDate.ToString())); } if (GetIndex(ImportReceipt.ImportReceiptFields.IsDeleted.ToString()) != -1) { if (!dataReader.IsDBNull(GetIndex(ImportReceipt.ImportReceiptFields.IsDeleted.ToString()))) { businessObject.IsDeleted = dataReader.GetInt32(GetIndex(ImportReceipt.ImportReceiptFields.IsDeleted.ToString())); } } if (GetIndex(ImportReceipt.ImportReceiptFields.TotalPrice.ToString()) != -1) { if (!dataReader.IsDBNull(GetIndex(ImportReceipt.ImportReceiptFields.TotalPrice.ToString()))) { businessObject.TotalPrice = dataReader.GetDecimal(GetIndex(ImportReceipt.ImportReceiptFields.TotalPrice.ToString())); } } if (GetIndex(ImportReceipt.ImportReceiptFields.UpdatedAt.ToString()) != -1) { if (!dataReader.IsDBNull(GetIndex(ImportReceipt.ImportReceiptFields.UpdatedAt.ToString()))) { businessObject.UpdatedAt = dataReader.GetDateTime(GetIndex(ImportReceipt.ImportReceiptFields.UpdatedAt.ToString())); } } if (GetIndex(ImportReceipt.ImportReceiptFields.UpdatedBy.ToString()) != -1) { if (!dataReader.IsDBNull(GetIndex(ImportReceipt.ImportReceiptFields.UpdatedBy.ToString()))) { businessObject.UpdatedBy = dataReader.GetInt32(GetIndex(ImportReceipt.ImportReceiptFields.UpdatedBy.ToString())); } } }
private async Task CreateImport_Accesory(List <ImportReceipt_Accessory> list, ImportReceipt inputModel) { try { foreach (var item in list) { item.ImportReceiptId = inputModel.Id; await _unitOfWork.ImportReceipt_AccessoryRepository.Add(item); var acc = await _unitOfWork.AccessoriesRepository.Get(c => c.Id == item.AccesoryId); acc.Quantity = acc.Quantity + item.Quantity; await _unitOfWork.AccessoriesRepository.Update(acc); await _unitOfWork.SaveChange(); } } catch (Exception ex) { throw ex; } }
public EntityBaseSql GetMyEntity(string entityName) { #region GetMyEntity if (entityName.Equals(Area.EntityName())) { return(new AreaSql()); } if (entityName.Equals(Connection.EntityName())) { return(new ConnectionSql()); } if (entityName.Equals(ConnectionStatus.EntityName())) { return(new ConnectionStatusSql()); } if (entityName.Equals(ConnectionType.EntityName())) { return(new ConnectionTypeSql()); } if (entityName.Equals(Contract.EntityName())) { return(new ContractSql()); } if (entityName.Equals(ContractStatus.EntityName())) { return(new ContractStatusSql()); } if (entityName.Equals(Customer.EntityName())) { return(new CustomerSql()); } if (entityName.Equals(CustomerFeedback.EntityName())) { return(new CustomerFeedbackSql()); } if (entityName.Equals(DetailImportReceipt.EntityName())) { return(new DetailImportReceiptSql()); } if (entityName.Equals(Device.EntityName())) { return(new DeviceSql()); } if (entityName.Equals(DeviceType.EntityName())) { return(new DeviceTypeSql()); } if (entityName.Equals(Employee.EntityName())) { return(new EmployeeSql()); } if (entityName.Equals(Fee.EntityName())) { return(new FeeSql()); } if (entityName.Equals(Image.EntityName())) { return(new ImageSql()); } if (entityName.Equals(ImportReceipt.EntityName())) { return(new ImportReceiptSql()); } if (entityName.Equals(Manufacturer.EntityName())) { return(new ManufacturerSql()); } if (entityName.Equals(Payment.EntityName())) { return(new PaymentSql()); } if (entityName.Equals(PaymentFee.EntityName())) { return(new PaymentFeeSql()); } if (entityName.Equals(Provider.EntityName())) { return(new ProviderSql()); } if (entityName.Equals(ServiceForm.EntityName())) { return(new ServiceFormSql()); } if (entityName.Equals(ServiceFormStatus.EntityName())) { return(new ServiceFormStatusSql()); } if (entityName.Equals(ServicePack.EntityName())) { return(new ServicePackSql()); } if (entityName.Equals(ServicePackFee.EntityName())) { return(new ServicePackFeeSql()); } if (entityName.Equals(Store.EntityName())) { return(new StoreSql()); } #endregion Console.WriteLine(entityName); return(null); }