Ejemplo n.º 1
0
        public ResultDTO Delete(DeleteAccountDTO obj)
        {
            ResultDTO accInfo = new ResultDTO();

            try
            {
                accInfo = _repository.DeleteAccount(obj);
            }
            catch (Exception ex)
            {
                Utilities.AppLog.WriteLog("DeleteAccount", ActionType.Delete, ex.Message.ToString(), obj.SessionKey);
                accInfo.StatusCode = Utilities.Common.ConvertErrorCodeToInt(RetCode.ECS9999);
                accInfo.SetContentMsg();
            }

            return(accInfo);
        }
        public static ResultDTO DeleteAccount(this IEntityBaseRepository <Account> repository, DeleteAccountDTO obj)
        {
            var result    = new ResultDTO();
            var dbContext = new ApplicationContext();

            var errorCode = new SqlParameter("ErrorCode", System.Data.SqlDbType.Int)
            {
                Direction = System.Data.ParameterDirection.Output
            };

            if (string.IsNullOrEmpty(obj.UserName) || string.IsNullOrEmpty(obj.SessionKey))
            {
                result.StatusCode = int.Parse(errorCode.Value.ToString(), 0);
            }
            else
            {
                dbContext.Database.ExecuteSqlCommand("EXEC [dbo].[sp_DeleteAccount] @UserName, @SessionKey, @errorCode out",
                                                     new SqlParameter("UserName", DB.SafeSQL(obj.UserName)),
                                                     new SqlParameter("SessionKey", DB.SafeSQL(obj.SessionKey)),
                                                     errorCode);
                result.StatusCode = int.Parse(errorCode.Value.ToString(), 0);
                result.SetContentMsg();
            }
            return(result);
        }