Пример #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);
        }
Пример #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));
        }
Пример #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));
        }
Пример #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));
        }
Пример #5
0
 public void Create(VendorDto vendor)
 {
     _vendorRepository.Create(_mapper.Map <Vendor>(vendor));
     _vendorRepository.SaveChanges();
 }
Пример #6
0
 public void Create(Vendor vendor)
 {
     _vendorRepository.Create(vendor);
 }
Пример #7
0
        public async Task <IActionResult> post([FromBody] Vendor vender)
        {
            await _gameRepository.Create(vender);

            return(new OkObjectResult(vender));
        }
Пример #8
0
 public void Create(Vendor vendor)
 {
     vendor.Id = new Guid();
     _vendorRepository.Create(vendor);
 }
Пример #9
0
        public async Task <ActionResult <Vendor> > PostVendor(Vendor vendor)
        {
            await _vendorRepository.Create(vendor);

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