Beispiel #1
0
        public IHttpActionResult Post(object obj)
        {
            try
            {
                long retId = _statusService.Add(obj);

                if (retId == 0)
                {
                    Log.Info($"{typeof(StatusController).FullName}||{UserEnvironment}||Add record not successful, Status Code is duplicate.");
                    return(Content(HttpStatusCode.Forbidden, "Status Code is Duplicate"));
                }


                Log.Info($"{typeof(StatusController).FullName}||{UserEnvironment}||Add record successful.");

                var    response = this.Request.CreateResponse(HttpStatusCode.Created);
                string test     = JsonConvert.SerializeObject(new
                {
                    id      = retId,
                    message = "Status added"
                });
                response.Content = new StringContent(test, Encoding.UTF8, "appliation/json");
                return(ResponseMessage(response));
            }
            catch (Exception e)
            {
                Log.Error(typeof(StatusController).FullName, e);

                return(Content(HttpStatusCode.NotAcceptable, e.Message));
            }
        }
Beispiel #2
0
 public IActionResult Create([Bind("Name,Description,HasProduct,ProductSequence,NoSupport,HasPurchase,PurchaseSequence,GenerateAssetOrLicense,HasAsset,AssetSequence,HasLicense,LicenceSequence,ToOrder,Ordered,OnStock,InUse,OutOfUse")] Status status)
 {
     if (ModelState.IsValid)
     {
         service.Add(status);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(status));
 }
        public StatusViewModel Add(StatusViewModel obj)
        {
            var status = Mapper.Map <StatusViewModel, Status>(obj);

            BeginTransaction();
            _statusService.Add(status);
            Commit();
            return(obj);
        }
Beispiel #4
0
        public IActionResult Add(Status status)
        {
            var result = _statusService.Add(status);

            if (result.Success)
            {
                return(Ok(result.Message));
            }

            return(BadRequest(result.Message));
        }
Beispiel #5
0
        public ActionResult Create([Bind(Include = "ID,Name")] Status status)
        {
            if (ModelState.IsValid)
            {
                _statusService.Add(status);
                _statusService.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(status));
        }
Beispiel #6
0
        public IActionResult Add(StatusDto statusDto)
        {
            var response = new ResponseViewModel();

            response = _statusService.Add(statusDto);

            if (!response.IsSuccess)
            {
                return(BadRequest(response));
            }

            return(Ok(response));
        }
Beispiel #7
0
 public IActionResult Create(StatusViewModel model)
 {
     if (ModelState.IsValid)
     {
         var status = new Status
         {
             Name        = model.Name,
             Description = model.Description
         };
         _statusService.Add(status);
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
Beispiel #8
0
        public async Task <IActionResult> Create(StatusCreateDto teamDto)
        {
            if (await _teamService.CheckExists(teamDto.ID))
            {
                return(BadRequest("Status ID already exists!"));
            }
            //var username = User.FindFirst(ClaimTypes.Name).Value;
            //glueIngredientDto.Updated_By = username;
            if (await _teamService.Add(teamDto))
            {
                return(NoContent());
            }

            throw new Exception("Creating the team failed on save");
        }
Beispiel #9
0
        public IActionResult Post([FromBody] StatusViewModel statusViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var status = _service.Add(statusViewModel);

            if (status is null)
            {
                return(NoContent());
            }

            return(CreatedAtAction(nameof(Get), new { status.Id }, status));
        }
Beispiel #10
0
        public async Task <JsonResult> CreateStatus(Status status)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var user = await _userManager.GetUserAsync(User);

                    await _statusService.Add(user, status);
                }
                catch (DbUpdateConcurrencyException)
                {
                    throw;
                }

                return(Json(null));
            }
            return(Json(null));
        }
Beispiel #11
0
        public HttpResponseMessage Post(HttpRequestMessage request, Status st)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (ModelState.IsValid)
                {
                    request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    var status = _statusService.Add(st);
                    _statusService.SaveChanges();

                    response = request.CreateResponse(HttpStatusCode.Created, status);
                }
                return response;
            }));
        }
Beispiel #12
0
        public ActionResult Add(Status status, string returnUrl = null)
        {
            ViewBag.returnUrl = returnUrl ?? Url.Content("~/");
            if (ModelState.IsValid)
            {
                var errors = _statusService.ValidateStatus(status);
                if (!errors.Any())
                {
                    _statusService.Add(status);
                    if (returnUrl != null)
                    {
                        return(Redirect(returnUrl));
                    }
                    return(RedirectToAction("Manage"));
                }
                ModelState.Merge(errors);
            }

            return(View(status));
        }