コード例 #1
0
        public ResponseBo Save(OptionSaveBo saveBo)
        {
            ResponseBo responseBo = new ResponseBo();

            try
            {
                using (SqlConnection conn = DbAccess.Connection.GetConn())
                {
                    var p = new DynamicParameters();
                    p.Add("@Message", dbType: DbType.String, direction: ParameterDirection.Output, size: 255);
                    p.Add("@IsSuccess", dbType: DbType.Boolean, direction: ParameterDirection.Output);

                    p.Add("@ProductCategoryId", saveBo.ProductCategoryId, DbType.Int32, ParameterDirection.Input);
                    p.Add("@Name", saveBo.Name, DbType.String, ParameterDirection.Input, 255);
                    p.Add("@OptionNameListStr", saveBo.OptionNameListStr, DbType.String, ParameterDirection.Input, int.MaxValue);

                    p.Add("@MyPersonId", saveBo.Session.MyPerson.Id, DbType.Int64, ParameterDirection.Input);
                    p.Add("@OperatorRealId", saveBo.Session.RealPerson.Id, DbType.Int64, ParameterDirection.Input);
                    p.Add("@LanguageId", saveBo.Session.RealPerson.LanguageId, DbType.Int32, ParameterDirection.Input);

                    conn.Execute("spOptionSave", p, commandType: CommandType.StoredProcedure);
                    responseBo.Message   = p.Get <string>("@Message");
                    responseBo.IsSuccess = p.Get <bool>("@IsSuccess");
                }
            }
            catch (Exception ex)
            {
                responseBo = base.SaveExLog(ex, this.GetType(), MethodBase.GetCurrentMethod().Name, saveBo);
            }

            return(responseBo);
        }
コード例 #2
0
        /// <summary>
        /// This method is smilar to 'Save' in 'PropertyController.cs'
        /// </summary>
        /// <param name="saveDto"></param>
        /// <returns></returns>
        public ResponseDto Save(OptionSaveDto saveDto)
        {
            //if(Session.RealPerson.Id)
            ResponseDto responseDto = new ResponseDto();

            OptionSaveBo saveBo = new OptionSaveBo()
            {
                ProductCategoryId = saveDto.ProductCategoryId,
                Name = saveDto.Name,
                OptionNameListStr = saveDto.OptionNameListStr,

                Session = Session
            };

            bool isValid = true;

            try
            {
                string[] listStr = null;
                if (saveBo.OptionNameListStr.IsNull())
                {
                    isValid = false;
                }
                else
                {
                    listStr = saveBo.OptionNameListStr.Split('\n');
                    if (listStr.IsNull() || listStr.Length == 0)
                    {
                        isValid = false;
                    }
                }

                List <string> nabersin = new List <string>();
                if (isValid)
                {
                    saveBo.OptionNameListStr = "";

                    List <string> tlistStr = new List <string>();
                    foreach (var item in listStr)
                    {
                        if (item.IsNull() || item.Trim().IsNull())
                        {
                            continue;
                        }

                        if (tlistStr.FirstOrDefault(f => string.Equals(f.ToLower(new CultureInfo("tr-Tr", false)), item.ToLower(new CultureInfo("tr-Tr", false)), StringComparison.CurrentCultureIgnoreCase)).IsNotNull())
                        {
                            nabersin.Add(item);
                            continue;
                        }

                        tlistStr.Add(item);
                        saveBo.OptionNameListStr += item + "\n";
                    }

                    saveBo.OptionNameListStr = saveBo.OptionNameListStr.Substring(0, saveBo.OptionNameListStr.Length - 1);
                }
            }
            catch (Exception ex)
            {
                isValid = false;
            }

            if (!isValid)
            {
                return(new ResponseDto()
                {
                    Message = "Geçersiz format",
                    IsSuccess = false
                });
            }

            ResponseBo responseBo = optionBusiness.Save(saveBo);

            responseDto = responseBo.ToResponseDto();

            return(responseDto);
        }