public async Task <bool> UpdateRequest(RequestUpdateDTO dto)
        {
            var rao = _mapper.Map <RequestUpdateRAO>(dto);

            if (await _repository.UpdateRequest(rao))
            {
                return(true);
            }

            throw new Exception("Item could not be updated.");
        }
Exemplo n.º 2
0
        public ResultDTO UpdateBanner(RequestUpdateDTO obj)
        {
            ResultDTO errorCode = new ResultDTO();

            try
            {
                errorCode = _repository.UpdateBanner(obj);
            }
            catch (Exception ex)
            {
                Utilities.AppLog.WriteLog("UpdateBanner", ActionType.Update, ex.Message.ToString(), obj.SessionKey);
                errorCode.StatusCode = Utilities.Common.ConvertErrorCodeToInt(RetCode.ECS9999);
                errorCode.StatusMsg  = ex.Message.ToString();
            }

            return(errorCode);
        }
Exemplo n.º 3
0
        public HttpResponseMessage Update([FromBody] RequestUpdateDTO request)
        {
            var res = MatrizDAL.Update(Matriz, request);

            return(SetResult(res));
        }
Exemplo n.º 4
0
        public HttpResponseMessage UpdateBannes(HttpRequestMessage request)
        {
            ResultDTO result = new ResultDTO();

            try
            {
                var    requestContext = HttpContext.Current.Request;
                var    pathFolder     = System.Web.Hosting.HostingEnvironment.MapPath(Common.GetConfigValue("PathBannesFolder"));
                string sessionKey     = requestContext.Form.Get("SessionKey");
                result = Common.CheckLogin(sessionKey);
                if (result.StatusCode != 0)
                {
                    return(CreateHttpResponse(request, () =>
                    {
                        var response = request.CreateResponse(HttpStatusCode.OK, result);
                        return response;
                    }));
                }
                if (requestContext.Files.Count < 1)
                {
                    result.StatusCode = int.Parse(RetCodeMsg.ECS0028, 0);
                    result.SetContentMsg();
                }
                else
                {
                    string fileName         = requestContext.Files[0].FileName;
                    string ext              = System.IO.Path.GetExtension(fileName);
                    string originalFileName = System.IO.Path.GetFileName(fileName);
                    result.Details = ConfigSystem.BannerFolder + originalFileName;
                    //To save file, use SaveAs method
                    if (System.IO.File.Exists(pathFolder + originalFileName))
                    {
                        System.IO.File.Delete(pathFolder + originalFileName);
                    }

                    //File will be saved in application root
                    requestContext.Files[0].SaveAs(pathFolder + originalFileName);
                    RequestUpdateDTO olalaObj = new RequestUpdateDTO();
                    olalaObj.SessionKey = sessionKey;
                    olalaObj.FileName   = originalFileName;
                    return(CreateHttpResponse(request, () =>
                    {
                        HttpResponseMessage response;
                        ResultDTO rs = _service.UpdateBanner(olalaObj);
                        response = request.CreateResponse(HttpStatusCode.OK, rs);
                        try
                        {
                            if (rs != null && rs.Details != null && rs.Details.ToString() != string.Empty && rs.Details.ToString().ToLower() != originalFileName.ToLower())
                            {
                                if (System.IO.File.Exists(pathFolder + rs.Details))
                                {
                                    System.IO.File.Delete(pathFolder + rs.Details);
                                }
                            }
                        }
                        catch (Exception) { }
                        return response;
                    }));
                }
            }
            catch (Exception ex)
            {
                result.StatusCode = 9999;
                result.Details    = ex.Message;

                return(CreateHttpResponse(request, () =>
                {
                    var response = request.CreateResponse(HttpStatusCode.OK, result);
                    return response;
                }));
            }

            return(CreateHttpResponse(request, () =>
            {
                var response = request.CreateResponse(HttpStatusCode.OK, result);
                return response;
            }));
        }
        public static ResultDTO UpdateBanner(this IEntityBaseRepository <Account> repository, RequestUpdateDTO obj)
        {
            var result    = new ResultDTO();
            var dbContext = new ApplicationContext();

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

            dbContext.Database.ExecuteSqlCommand("EXEC [dbo].[sp_UpdateBanner] @FileName, @SessionKey,@OldFileName out, @errorCode out",
                                                 new SqlParameter("FileName", obj.FileName),
                                                 new SqlParameter("SessionKey", DB.SafeSQL(obj.SessionKey)),
                                                 oldFileName,
                                                 errorCode);
            result.StatusCode = int.Parse(errorCode.Value.ToString(), 0);
            result.SetContentMsg();
            result.Details = oldFileName.Value.ToString();

            return(result);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Generamos la actualización de un vector en una matriz dada
 /// </summary>
 /// <param name="myMatriz"></param>
 /// <param name="obj"></param>
 /// <returns></returns>
 public static int Update(Matriz myMatriz, RequestUpdateDTO obj)
 {
     myMatriz.List.SetValue(obj.Value, obj.X, obj.Y, obj.Z);
     return(obj.Value);
 }