Esempio n. 1
0
 public static bool ValidateUpdate(ServiceFormStatus obj, out string errorCode, out string errorMess)
 {
     errorCode = null;
     errorMess = null;
     try
     {
         if (obj == null)
         {
             errorCode = ErrorCodeEnum.DataInputWrong.ToString();
             return(false);
         }
         if (obj.Name == null)
         {
             errorCode = ErrorCodeEnum.DataInputWrong.ToString();
             errorMess = "Name not allow null value";
             return(false);
         }
     }
     catch (Exception ex)
     {
         Logger.Write(ex.ToString());
         throw;
     }
     return(true);
 }
 internal static void RemoveMemory(ServiceFormStatus objectValue)
 {
     if (DicServiceFormStatus.ContainsKey(objectValue.Id))
     {
         DicServiceFormStatus.Remove(objectValue.Id);
     }
 }
Esempio n. 3
0
 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 override List <BaseEntity> PopulateBusinessObjectFromReader(IDataReader dataReader)
        {
            var list = new List <BaseEntity>();

            _dicIndex = new Dictionary <string, int>();
            while (dataReader.Read())
            {
                var businessObject = new ServiceFormStatus();
                PopulateBusinessObjectFromReader(businessObject, dataReader);
                list.Add(businessObject);
            }

            return(list);
        }
        internal static void SetMemory(ServiceFormStatus 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;
            }
            DicServiceFormStatus[objectValue.Id] = objectValue;
        }
        internal void PopulateBusinessObjectFromReader(ServiceFormStatus businessObject, IDataReader dataReader)
        {
            if (_dicIndex.Count == 0)
            {
                FillDicIndex(dataReader);
            }

            if (GetIndex(ServiceFormStatus.ServiceFormStatusFields.CreatedAt.ToString()) != -1)
            {
                if (!dataReader.IsDBNull(GetIndex(ServiceFormStatus.ServiceFormStatusFields.CreatedAt.ToString())))
                {
                    businessObject.CreatedAt = dataReader.GetDateTime(GetIndex(ServiceFormStatus.ServiceFormStatusFields.CreatedAt.ToString()));
                }
            }

            if (GetIndex(ServiceFormStatus.ServiceFormStatusFields.CreatedBy.ToString()) != -1)
            {
                if (!dataReader.IsDBNull(GetIndex(ServiceFormStatus.ServiceFormStatusFields.CreatedBy.ToString())))
                {
                    businessObject.CreatedBy = dataReader.GetInt32(GetIndex(ServiceFormStatus.ServiceFormStatusFields.CreatedBy.ToString()));
                }
            }

            if (GetIndex(ServiceFormStatus.ServiceFormStatusFields.Description.ToString()) != -1)
            {
                if (!dataReader.IsDBNull(GetIndex(ServiceFormStatus.ServiceFormStatusFields.Description.ToString())))
                {
                    businessObject.Description = dataReader.GetString(GetIndex(ServiceFormStatus.ServiceFormStatusFields.Description.ToString()));
                }
            }

            businessObject.Id = dataReader.GetInt32(GetIndex(ServiceFormStatus.ServiceFormStatusFields.Id.ToString()));

            if (GetIndex(ServiceFormStatus.ServiceFormStatusFields.IsDeleted.ToString()) != -1)
            {
                if (!dataReader.IsDBNull(GetIndex(ServiceFormStatus.ServiceFormStatusFields.IsDeleted.ToString())))
                {
                    businessObject.IsDeleted = dataReader.GetInt32(GetIndex(ServiceFormStatus.ServiceFormStatusFields.IsDeleted.ToString()));
                }
            }

            if (GetIndex(ServiceFormStatus.ServiceFormStatusFields.Name.ToString()) != -1)
            {
                businessObject.Name = dataReader.GetString(GetIndex(ServiceFormStatus.ServiceFormStatusFields.Name.ToString()));
            }

            if (GetIndex(ServiceFormStatus.ServiceFormStatusFields.UpdatedAt.ToString()) != -1)
            {
                if (!dataReader.IsDBNull(GetIndex(ServiceFormStatus.ServiceFormStatusFields.UpdatedAt.ToString())))
                {
                    businessObject.UpdatedAt = dataReader.GetDateTime(GetIndex(ServiceFormStatus.ServiceFormStatusFields.UpdatedAt.ToString()));
                }
            }

            if (GetIndex(ServiceFormStatus.ServiceFormStatusFields.UpdatedBy.ToString()) != -1)
            {
                if (!dataReader.IsDBNull(GetIndex(ServiceFormStatus.ServiceFormStatusFields.UpdatedBy.ToString())))
                {
                    businessObject.UpdatedBy = dataReader.GetInt32(GetIndex(ServiceFormStatus.ServiceFormStatusFields.UpdatedBy.ToString()));
                }
            }
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        public async Task <IHttpActionResult> Post([FromBody] ServiceFormStatus 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 Tạo key
                var oldKey = Memory.Memory.GetMaxKey(req.GetName());
                int newKey = oldKey + 1;
                // set key
                req.Id = newKey;
                #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"));
        }