public async Task <IActionResult> Edit(int id, [Bind("Name,Id,IsActive,CreDate")] PaymentTypeEntity paymentTypeEntity)
        {
            if (id != paymentTypeEntity.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _paymentTypeRepository.UpdateAsync(paymentTypeEntity);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PaymentTypeEntityExists(paymentTypeEntity.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(paymentTypeEntity));
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条记录,返回新的ID号。需要有一个单一主键,并且开启有标识符属性(异步方式)
        /// </summary>
        /// <param name="entity">实体模型</param>
        /// <returns></returns>
        public virtual async Task <int> InsertAsync(PaymentTypeEntity entity)
        {
            if (entity.TypeID <= 0)
            {
                entity.TypeID = GetNewID();
            }
            Dictionary <string, object> dict = new Dictionary <string, object>();

            GetParameters(entity, dict);

            string strSQL = "insert into PaymentType (" +
                            "TypeID," +
                            "TypeName," +
                            "Intro," +
                            "Discount," +
                            "OrderSort," +
                            "IsDefault," +
                            "IsDisabled," +
                            "Category) " +
                            "values(" +
                            "@TypeID," +
                            "@TypeName," +
                            "@Intro," +
                            "@Discount," +
                            "@OrderSort," +
                            "@IsDefault," +
                            "@IsDisabled," +
                            "@Category)";

            if (await Task.Run(() => _DB.ExeSQLResult(strSQL, dict)))
            {
                return(DataConverter.CLng(entity.TypeID));
            }
            return(-1);
        }
Esempio n. 3
0
        /// <summary>
        /// 增加一条记录
        /// </summary>
        /// <param name="entity">实体模型</param>
        /// <returns></returns>
        public virtual bool Add(PaymentTypeEntity entity)
        {
            if (entity.TypeID <= 0)
            {
                entity.TypeID = GetNewID();
            }
            Dictionary <string, object> dict = new Dictionary <string, object>();

            GetParameters(entity, dict);

            string strSQL = "insert into PaymentType (" +
                            "TypeID," +
                            "TypeName," +
                            "Intro," +
                            "Discount," +
                            "OrderSort," +
                            "IsDefault," +
                            "IsDisabled," +
                            "Category) " +
                            "values(" +
                            "@TypeID," +
                            "@TypeName," +
                            "@Intro," +
                            "@Discount," +
                            "@OrderSort," +
                            "@IsDefault," +
                            "@IsDisabled," +
                            "@Category)";

            return(_DB.ExeSQLResult(strSQL, dict));
        }
Esempio n. 4
0
        public DataResultArgs <bool> Set_PaymentType(PaymentTypeEntity entity)
        {
            try
            {
                DataProcess.ControlAdminAuthorization(true);

                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@DatabaseProcess", entity.DatabaseProcess);
                cmd.Parameters.AddWithValue("@id", entity.Id);
                cmd.Parameters.AddWithValue("@name", entity.Name);
                cmd.Parameters.AddWithValue("@amount", entity.Amount);
                cmd.Parameters.AddWithValue("@isActive", entity.IsActive);
                using (SqlConnection con = Connection.Conn)
                {
                    con.Open();
                    DataResultArgs <bool> resultSet = DataProcess.ExecuteProc(con, cmd, "set_PaymentType");
                    con.Close();
                    staticPaymentTypeList = null;
                    return(resultSet);
                }
            }
            catch (Exception ex)
            {
                DataResultArgs <bool> result = new DataResultArgs <bool>();
                result.HasError         = true;
                result.ErrorDescription = ex.Message;
                return(result);
            }
        }
        public async Task <IActionResult> Create([Bind("Name,Id")] PaymentTypeEntity paymentTypeEntity)
        {
            if (ModelState.IsValid)
            {
                await _paymentTypeRepository.AddAsync(paymentTypeEntity);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(paymentTypeEntity));
        }
Esempio n. 6
0
 /// <summary>
 /// 把实体类转换成键/值对集合
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="dict"></param>
 private static void GetParameters(PaymentTypeEntity entity, Dictionary <string, object> dict)
 {
     dict.Add("TypeID", entity.TypeID);
     dict.Add("TypeName", entity.TypeName);
     dict.Add("Intro", entity.Intro);
     dict.Add("Discount", entity.Discount);
     dict.Add("OrderSort", entity.OrderSort);
     dict.Add("IsDefault", entity.IsDefault);
     dict.Add("IsDisabled", entity.IsDisabled);
     dict.Add("Category", entity.Category);
 }
Esempio n. 7
0
        public DataResultArgs <List <PaymentTypeEntity> > Get_PaymentType(SearchEntity entity)
        {
            DataProcess.ControlAdminAuthorization();

            if (staticPaymentTypeList == null)
            {
                DataResultArgs <List <PaymentTypeEntity> > resultSet = new DataResultArgs <List <PaymentTypeEntity> >();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@id", entity.Id);
                cmd.Parameters.AddWithValue("@isActive", entity.IsActive);
                cmd.Parameters.AddWithValue("@isDeleted", entity.IsDeleted);
                using (SqlConnection con = Connection.Conn)
                {
                    con.Open();
                    DataResultArgs <SqlDataReader> result =
                        DataProcess.ExecuteProcDataReader(con, cmd, "get_PaymentType");
                    if (result.HasError)
                    {
                        resultSet.HasError         = result.HasError;
                        resultSet.ErrorDescription = result.ErrorDescription;
                        resultSet.ErrorCode        = result.ErrorCode;
                    }
                    else
                    {
                        SqlDataReader            dr  = result.Result;
                        List <PaymentTypeEntity> lst = new List <PaymentTypeEntity>();
                        PaymentTypeEntity        elist;
                        while (dr.Read())
                        {
                            elist           = new PaymentTypeEntity();
                            elist.Id        = GeneralFunctions.GetData <Int32>(dr["id"]);
                            elist.Name      = GeneralFunctions.GetData <String>(dr["name"]);
                            elist.Amount    = GeneralFunctions.GetData <Decimal?>(dr["amount"]);
                            elist.IsActive  = GeneralFunctions.GetData <Boolean?>(dr["isActive"]);
                            elist.UpdatedOn = GeneralFunctions.GetData <DateTime>(dr["updatedOn"]);
                            lst.Add(elist);
                        }


                        dr.Close();

                        resultSet.Result = lst;
                    }
                    con.Close();
                }

                staticPaymentTypeList = resultSet;
            }

            return(staticPaymentTypeList);
        }
Esempio n. 8
0
        /// <summary>
        /// 通过数据读取器生成实体类
        /// </summary>
        /// <param name="rdr"></param>
        /// <returns></returns>
        private static PaymentTypeEntity GetEntityFromrdr(NullableDataReader rdr)
        {
            PaymentTypeEntity info = new PaymentTypeEntity();

            info.TypeID     = rdr.GetInt32("TypeID");
            info.TypeName   = rdr.GetString("TypeName");
            info.Intro      = rdr.GetString("Intro");
            info.Discount   = rdr.GetDouble("Discount");
            info.OrderSort  = rdr.GetInt32("OrderSort");
            info.IsDefault  = rdr.GetBoolean("IsDefault");
            info.IsDisabled = rdr.GetBoolean("IsDisabled");
            info.Category   = rdr.GetInt32("Category");
            return(info);
        }
Esempio n. 9
0
        /// <summary>
        /// 获取实体(异步方式)
        /// </summary>
        /// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
        /// <param name="dict">参数的名/值集合</param>
        /// <returns></returns>
        public virtual async Task <PaymentTypeEntity> GetEntityAsync(string strWhere, Dictionary <string, object> dict = null)
        {
            PaymentTypeEntity obj    = null;
            string            strSQL = "select top 1 * from PaymentType where 1=1 " + strWhere;

            using (NullableDataReader reader = await Task.Run(() => _DB.GetDataReader(strSQL, dict)))
            {
                if (reader.Read())
                {
                    obj = GetEntityFromrdr(reader);
                }
            }
            return(obj);
        }
        public DataResultArgs <bool> InsertOrUpdatePaymentType(string encryptId, PaymentTypeEntity paymentTypeEntity)
        {
            DatabaseProcess currentProcess = DatabaseProcess.Add;

            paymentTypeEntity.Id = 0;
            if (!string.IsNullOrEmpty(encryptId))
            {
                int.TryParse(Cipher.Decrypt(encryptId), out var id);
                if (id > 0)
                {
                    currentProcess = DatabaseProcess.Update;
                }
                paymentTypeEntity.Id = id;
            }

            paymentTypeEntity.DatabaseProcess = currentProcess;

            return(new PaymentTypeBusiness().Set_PaymentType(paymentTypeEntity));
        }
Esempio n. 11
0
        /// <summary>
        /// 更新一条记录(异步方式)
        /// </summary>
        /// <param name="entity">实体模型</param>
        /// <returns></returns>
        public virtual async Task <bool> UpdateAsync(PaymentTypeEntity entity)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            GetParameters(entity, dict);
            string strSQL = "Update PaymentType SET " +
                            "TypeName = @TypeName," +
                            "Intro = @Intro," +
                            "Discount = @Discount," +
                            "OrderSort = @OrderSort," +
                            "IsDefault = @IsDefault," +
                            "IsDisabled = @IsDisabled," +
                            "Category = @Category" +
                            " WHERE " +

                            "TypeID = @TypeID";

            return(await Task.Run(() => _DB.ExeSQLResult(strSQL, dict)));
        }
        public DataResultArgs <bool> DeletePaymentType(string id)
        {
            DataResultArgs <bool> result = new DataResultArgs <bool>
            {
                HasError = true, ErrorDescription = "Id bilgisine ulaşılamadı."
            };

            if (!string.IsNullOrEmpty(id))
            {
                int.TryParse(Cipher.Decrypt(id), out var idInt);
                if (idInt > 0)
                {
                    PaymentTypeEntity entity = new PaymentTypeEntity
                    {
                        Id = idInt, DatabaseProcess = DatabaseProcess.Deleted
                    };

                    result = new PaymentTypeBusiness().Set_PaymentType(entity);
                }
            }

            return(result);
        }
Esempio n. 13
0
 /// <summary>
 /// 增加或更新一条记录(异步方式)
 /// </summary>
 /// <param name="entity">实体模型</param>
 /// <param name="IsSave">是否增加</param>
 /// <returns></returns>
 public virtual async Task <bool> AddOrUpdateAsync(PaymentTypeEntity entity, bool IsSave)
 {
     return(IsSave ? await AddAsync(entity) : await UpdateAsync(entity));
 }
Esempio n. 14
0
 /// <summary>
 /// 增加或更新一条记录
 /// </summary>
 /// <param name="entity">实体模型</param>
 /// <param name="IsSave">是否增加</param>
 /// <returns></returns>
 public virtual bool AddOrUpdate(PaymentTypeEntity entity, bool IsSave)
 {
     return(IsSave ? Add(entity) : Update(entity));
 }