Exemple #1
0
 public HttpResponseMessage Add(StatusVM statusVM, string token)
 {
     try
     {
         //check token info
         var isAllow = iAccountService.IsTokenAvailable(token);
         if (!isAllow)
         {
             return(PostResponseFail(HttpStatusCode.ExpectationFailed, ExceptionMessageConstant.TokenNotAvailable));
         }
         //proceed request
         var tokenizedUserId = iAccountService.GetUserIdByToken(token);
         statusVM.UserId = tokenizedUserId;
         iStatusService.AddStatus(statusVM);
         return(PostResponseSuccess(HttpStatusCode.OK, SucessMessageConstant.RequestHandleSuccessful));
     }
     catch (NullReferenceException)
     {
         return(PostResponseFail(HttpStatusCode.ExpectationFailed, ExceptionMessageConstant.RequestNullExceptionMassge));
     }
     catch (Exception ex)
     {
         return(PostResponseFail(HttpStatusCode.ExpectationFailed, ex.Message));
     }
 }
Exemple #2
0
        public ActionResult save([Bind(Include = "ID,Name")] StatusViewModel statusView)
        {
            bool status = false;

            if (statusView.Id == 0)
            {
                var statusdata = Mapper.Map <IEnumerable <Status>, IEnumerable <StatusViewModel> >(_statusService.GetAll());
                var mode       = (from s in statusdata where s.Id == statusView.Id select s.Name).ToString();
                if (mode == statusView.Name)
                {
                    status = false;
                    return(Json(new
                    {
                        status = status
                    }));
                }
                _statusService.AddStatus(Mapper.Map <StatusViewModel, Status>(statusView));
                _statusService.SaveChange();
                status = true;
            }
            else
            {
                //_statusService.UpdateStatus(Mapper.Map<StatusViewModel, Status>(statusView)).State = EntityState.Modified;
                //_statusService.SaveChange();
                status = true;
            }
            return(Json(new
            {
                status = status
            }));
        }
        public IActionResult AddStatus(Status status)
        {
            if (status == null)
            {
                return(BadRequest());
            }
            var re = _IStatusService.AddStatus(status);

            return(Ok(re));
        }
Exemple #4
0
        public IActionResult Post([FromBody] Status status)
        {
            if (status == null)
            {
                return(BadRequest());
            }
            else if (status.Id == 0)
            {
                _stat.AddStatus(status);

                return(Ok());
            }
            else
            {
                _stat.UpdateStatus(status);

                return(Ok());
            }
        }
Exemple #5
0
        public async Task <IHttpActionResult> PostStatus(Status status)
        {
            try
            {
                var result = await _statusService.AddStatus(status);

                return(this.JsonDataResult(result));
            }
            catch (Exception e)
            {
                return(new InternalServerErrorResult(this));
            }


            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
        }
        public IActionResult CreateStatus(StatusModel model)
        {
            ViewBag.IsLogin = !string.IsNullOrEmpty(cache.GetString("user"));
            if (ViewBag.IsLogin)
            {
                ViewBag.User = JsonConvert.DeserializeObject <AccountModel>(cache.GetString("user"));
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
            if (!ViewBag.User.IsAdmin)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (ModelState.IsValid)
            {
                statussvc.AddStatus(model);
                return(RedirectToAction(nameof(ProjectSystem)));
            }
            return(View(model));
        }
 public IActionResult AddStatus(Status status)
 {
     //UserService service = new UserService();
     return(Ok(_statusService.AddStatus(status)));
 }
Exemple #8
0
 public ActionResult Create(Status obj)
 {
     _statusService.AddStatus(obj);
     return(RedirectToAction("Index"));
 }
 public ActionResult AddStatus(ObjStatus objStatus)
 {
     _statusService.AddStatus(objStatus);
     return(RedirectToAction("Statuses"));
 }