Exemplo n.º 1
0
        public async Task <ResponseModel> PostAsync([FromBody]   string value)
        {
            string        NewInsertionID = "0";
            ResponseModel response;
            Vendor        newVendor  = JsonConvert.DeserializeObject <Vendor>(value);
            int           created_by = newVendor.created_by;

            NewInsertionID = await _VendorRepo.Create(newVendor);

            response = new ResponseModel {
                Data = NewInsertionID, Status = System.Net.HttpStatusCode.OK, Message = "Success"
            };
            var eventModel = new EventModel(vendorEventTableName)
            {
                EventName   = create_vendor,
                EntityId    = Int32.Parse(NewInsertionID),
                RefrenceId  = 0,
                UserId      = created_by,
                EventNoteId = Int32.Parse(NewInsertionID)
            };
            await _eventRepo.AddEventAsync(eventModel);

            var userEvent = new EventModel(userEventTableName)
            {
                EventName   = create_vendor,
                EntityId    = created_by,
                RefrenceId  = Convert.ToInt32(NewInsertionID),
                UserId      = created_by,
                EventNoteId = Int32.Parse(NewInsertionID)
            };
            await _eventRepo.AddEventAsync(userEvent);

            return(response);
        }
Exemplo n.º 2
0
        public ActionResult Update(Vendor vendor)
        {
            ApiResult <Vendor> apiResult;

            if (ModelState.IsValid)
            {
                if (vendor.Id > 0)
                {
                    apiResult = TryExecute(() =>
                    {
                        var newVendor = new Vendor
                        {
                            Title              = vendor.Title,
                            Email              = vendor.Email,
                            Phone              = vendor.Phone,
                            WebSite            = vendor.WebSite,
                            Address            = vendor.Address,
                            ContactPerson      = vendor.ContactPerson,
                            ContactPersonEmail = vendor.ContactPersonEmail,
                            ContactPersonPhone = vendor.ContactPersonPhone,
                            Description        = vendor.Description,
                        };
                        _vendorRepository.Update(vendor);
                        _unitOfWork.Commit();
                        return(vendor);
                    }, "Vendor updated sucessfully");
                }
                else
                {
                    apiResult = TryExecute(() =>
                    {
                        var newVendor = new Vendor
                        {
                            Id                 = vendor.Id,
                            Title              = vendor.Title,
                            Email              = vendor.Email,
                            Phone              = vendor.Phone,
                            WebSite            = vendor.WebSite,
                            Address            = vendor.Address,
                            ContactPerson      = vendor.ContactPerson,
                            ContactPersonEmail = vendor.ContactPersonEmail,
                            ContactPersonPhone = vendor.ContactPersonPhone,
                            Description        = vendor.Description,
                        };
                        _vendorRepository.Create(vendor);
                        _unitOfWork.Commit();
                        return(vendor);
                    }, "Vendor created sucessfully");
                }
            }
            else
            {
                apiResult = ApiResultFromModelErrors <Vendor>();
            }

            return(Json(apiResult, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        // POST: api/Vendors
        public IHttpActionResult Post([FromBody] Dictionary <Guid, object> data)
        {
            var appId = Request.GetApplicationIdFromReferrer();

            if (appId == null)
            {
                return(InternalServerError());
            }

            var vendor = applicationGridService.MapDataToEntity <Vendor>(appId.Value, data);

            vendorRepository.Create(vendor);

            return(Ok(data));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> RegisterVendor(RegisterVendorViewModel model, string returnUrl = null)
        {
            ViewData["ReturnUrl"] = returnUrl;
            if (ModelState.IsValid)
            {
                model.UserName = User.Identity.Name;
                var result = _vendorRepository.Create(model, HttpContext.User);
                if (result == Result.Success)
                {
                    _logger.LogInformation("User created a new account with password.");
                    var user = await _vendorRepository.FindByNameAsync(model.VendorName);

                    _logger.LogInformation("User created a new Vendor.");
                    return(RedirectToLocal("/home/index"));
                }
                // AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemplo n.º 5
0
 public void Create(VendorDto vendor)
 {
     _vendorRepository.Create(_mapper.Map <Vendor>(vendor));
     _vendorRepository.SaveChanges();
 }
Exemplo n.º 6
0
 public void Create(Vendor vendor)
 {
     _vendorRepository.Create(vendor);
 }
Exemplo n.º 7
0
        public async Task <IActionResult> post([FromBody] Vendor vender)
        {
            await _gameRepository.Create(vender);

            return(new OkObjectResult(vender));
        }
Exemplo n.º 8
0
 public void Create(Vendor vendor)
 {
     vendor.Id = new Guid();
     _vendorRepository.Create(vendor);
 }
Exemplo n.º 9
0
        public async Task <ActionResult <Vendor> > PostVendor(Vendor vendor)
        {
            await _vendorRepository.Create(vendor);

            return(CreatedAtAction("GetVendor", new { id = vendor.Id }, vendor));
        }