public static bool ValidateUpdate(DetailImportReceipt obj, out string errorCode, out string errorMess) { errorCode = null; errorMess = null; try { if (obj == null) { errorCode = ErrorCodeEnum.DataInputWrong.ToString(); return(false); } if (obj.IdDevice == null) { errorCode = ErrorCodeEnum.DataInputWrong.ToString(); errorMess = "IdDevice not allow null value"; return(false); } if (obj.IdImportReceipt == null) { errorCode = ErrorCodeEnum.DataInputWrong.ToString(); errorMess = "IdImportReceipt not allow null value"; return(false); } } catch (Exception ex) { Logger.Write(ex.ToString()); throw; } return(true); }
public async Task <IHttpActionResult> Post([FromBody] DetailImportReceipt req) { try { string errorMessage = "UnknowError"; string errorCode = ErrorCodeEnum.UnknownError.ToString(); #region token var header = Request.Headers; if (header.Authorization == null) { return(StatusCode(HttpStatusCode.Unauthorized)); } var token = header.Authorization.Parameter; Employee employee; if (string.IsNullOrWhiteSpace(token) || !TokenManager.ValidateToken(token, out employee)) { return(StatusCode(HttpStatusCode.Unauthorized)); } #endregion if (!Operator.IsAdmin(employee)) { return(Ok(new RequestErrorCode(false, ErrorCodeEnum.Error_NotHavePermision.ToString(), "Khong co quyen"))); } #region Validate if (!Validate(req, out errorCode, out errorMessage)) { return(Ok(new RequestErrorCode(false, errorCode, errorMessage))); } #endregion #region Process req.CreatedAt = DateTime.Now; req.CreatedBy = employee.Id; req.IsDeleted = 0; UpdateEntitySql updateEntitySql = new UpdateEntitySql(); var lstCommand = new List <EntityCommand>(); lstCommand.Add(new EntityCommand { BaseEntity = new Entity.Entity(req), EntityAction = EntityAction.Insert }); bool isOkDone = updateEntitySql.UpdateDefault(lstCommand); if (!isOkDone) { return(Ok(new RequestErrorCode(false, errorCode, errorMessage))); } #endregion // update memory MemorySet.UpdateAndInsertEntity(req); var result = new RequestErrorCode(true); result.DataResult = req; return(Ok(result)); } catch (Exception ex) { Logger.Write(ex.ToString()); } return(BadRequest("Unknow")); }
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(), }); }
internal static void SetMemory(DetailImportReceipt objectValue) { var key = new DetailImportReceiptKeys { IdDevice = objectValue.IdDevice, IdImportReceipt = objectValue.IdImportReceipt }; DicDetailImportReceipt[key] = objectValue; }
internal static void RemoveMemory(DetailImportReceipt objectValue) { var key = new DetailImportReceiptKeys { IdDevice = objectValue.IdDevice, IdImportReceipt = objectValue.IdImportReceipt }; if (DicDetailImportReceipt.ContainsKey(key)) { DicDetailImportReceipt.Remove(key); } }
public override List <BaseEntity> PopulateBusinessObjectFromReader(IDataReader dataReader) { var list = new List <BaseEntity>(); _dicIndex = new Dictionary <string, int>(); while (dataReader.Read()) { var businessObject = new DetailImportReceipt(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); }
private bool ValidateUpdate(DetailImportReceipt obj, out string errorCode, out string errorMess) { errorCode = null; errorMess = null; try { } catch (Exception ex) { Logger.Write(ex.ToString()); throw; } return(true); }
internal void PopulateBusinessObjectFromReader(DetailImportReceipt businessObject, IDataReader dataReader) { if (_dicIndex.Count == 0) { FillDicIndex(dataReader); } if (GetIndex(DetailImportReceipt.DetailImportReceiptFields.CreatedAt.ToString()) != -1) { if (!dataReader.IsDBNull(GetIndex(DetailImportReceipt.DetailImportReceiptFields.CreatedAt.ToString()))) { businessObject.CreatedAt = dataReader.GetDateTime(GetIndex(DetailImportReceipt.DetailImportReceiptFields.CreatedAt.ToString())); } } if (GetIndex(DetailImportReceipt.DetailImportReceiptFields.CreatedBy.ToString()) != -1) { if (!dataReader.IsDBNull(GetIndex(DetailImportReceipt.DetailImportReceiptFields.CreatedBy.ToString()))) { businessObject.CreatedBy = dataReader.GetInt32(GetIndex(DetailImportReceipt.DetailImportReceiptFields.CreatedBy.ToString())); } } businessObject.IdDevice = dataReader.GetInt32(GetIndex(DetailImportReceipt.DetailImportReceiptFields.IdDevice.ToString())); businessObject.IdImportReceipt = dataReader.GetInt32(GetIndex(DetailImportReceipt.DetailImportReceiptFields.IdImportReceipt.ToString())); if (GetIndex(DetailImportReceipt.DetailImportReceiptFields.IsDeleted.ToString()) != -1) { if (!dataReader.IsDBNull(GetIndex(DetailImportReceipt.DetailImportReceiptFields.IsDeleted.ToString()))) { businessObject.IsDeleted = dataReader.GetInt32(GetIndex(DetailImportReceipt.DetailImportReceiptFields.IsDeleted.ToString())); } } if (GetIndex(DetailImportReceipt.DetailImportReceiptFields.Price.ToString()) != -1) { if (!dataReader.IsDBNull(GetIndex(DetailImportReceipt.DetailImportReceiptFields.Price.ToString()))) { businessObject.Price = dataReader.GetDecimal(GetIndex(DetailImportReceipt.DetailImportReceiptFields.Price.ToString())); } } if (GetIndex(DetailImportReceipt.DetailImportReceiptFields.Quantity.ToString()) != -1) { if (!dataReader.IsDBNull(GetIndex(DetailImportReceipt.DetailImportReceiptFields.Quantity.ToString()))) { businessObject.Quantity = dataReader.GetInt32(GetIndex(DetailImportReceipt.DetailImportReceiptFields.Quantity.ToString())); } } if (GetIndex(DetailImportReceipt.DetailImportReceiptFields.UpdatedAt.ToString()) != -1) { if (!dataReader.IsDBNull(GetIndex(DetailImportReceipt.DetailImportReceiptFields.UpdatedAt.ToString()))) { businessObject.UpdatedAt = dataReader.GetDateTime(GetIndex(DetailImportReceipt.DetailImportReceiptFields.UpdatedAt.ToString())); } } if (GetIndex(DetailImportReceipt.DetailImportReceiptFields.UpdatedBy.ToString()) != -1) { if (!dataReader.IsDBNull(GetIndex(DetailImportReceipt.DetailImportReceiptFields.UpdatedBy.ToString()))) { businessObject.UpdatedBy = dataReader.GetInt32(GetIndex(DetailImportReceipt.DetailImportReceiptFields.UpdatedBy.ToString())); } } }
public async Task <IHttpActionResult> Delete([FromBody] DetailImportReceipt req) { try { string errorMessage = "UnknowError"; string errorCode = ErrorCodeEnum.UnknownError.ToString(); #region token var header = Request.Headers; if (header.Authorization == null) { return(StatusCode(HttpStatusCode.Unauthorized)); } var token = header.Authorization.Parameter; Employee employee; if (string.IsNullOrWhiteSpace(token) || !TokenManager.ValidateToken(token, out employee)) { return(StatusCode(HttpStatusCode.Unauthorized)); } #endregion if (!Operator.IsAdmin(employee)) { return(Ok(new RequestErrorCode(false, ErrorCodeEnum.Error_NotHavePermision.ToString(), "Khong co quyen"))); } #region Check exist var obj = MemoryInfo.GetDetailImportReceipt(req.GetDetailImportReceiptKeys()); if (obj == null) { return(Ok(new RequestErrorCode(false, ErrorCodeEnum.DataNotExist.ToString(), "Khong ton tai"))); } #endregion bool isHasDeleteProperties = obj.GetType().GetProperty("IsDeleted") != null; if (!isHasDeleteProperties) { return(Ok(new RequestErrorCode(false, ErrorCodeEnum.DataNotExist.ToString(), "Khong ton tai"))); } obj.IsDeleted = 1; #region Process UpdateEntitySql updateEntitySql = new UpdateEntitySql(); var lstCommand = new List <EntityCommand>(); lstCommand.Add(new EntityCommand { BaseEntity = new Entity.Entity(obj), EntityAction = EntityAction.Update }); bool isOkDone = updateEntitySql.UpdateDefault(lstCommand); if (!isOkDone) { return(Ok(new RequestErrorCode(false, errorCode, errorMessage))); } #endregion // update memory MemorySet.UpdateAndInsertEntity(obj); var result = new RequestErrorCode(true); result.DataResult = obj; return(Ok(result)); } catch (Exception ex) { Logger.Write(ex.ToString()); } return(BadRequest("Unknow")); }
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); }