コード例 #1
0
        public bool UpdateVendorServices(UpdateVendorDto updateVendorDto, int id)
        {
            Vendor vendorUpdate = new Vendor();

            vendorUpdate.Id          = id;
            vendorUpdate.Adress      = updateVendorDto.Adress;
            vendorUpdate.Date        = updateVendorDto.Date;
            vendorUpdate.Email       = updateVendorDto.Email;
            vendorUpdate.Gender      = updateVendorDto.Gender;
            vendorUpdate.PhoneNumber = updateVendorDto.PhoneNumber;
            vendorUpdate.VendorName  = updateVendorDto.VendorName;
            vendorUpdate.Title       = updateVendorDto.Title;


            int result = _vendorRepository.UpdateVendorRepository(vendorUpdate);

            if (result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        public IActionResult UpdateVendor([FromRoute] int id, [FromBody] JsonPatchDocument <UpdateVendorDto> vendorPatch)
        {
            var             vendor          = _IVendorServices.GetVendorByIdervices(id);
            UpdateVendorDto updateVendorDto = new UpdateVendorDto();

            updateVendorDto.Adress      = vendor.Adress;
            updateVendorDto.Date        = vendor.Date;
            updateVendorDto.Email       = vendor.Email;
            updateVendorDto.Gender      = vendor.Gender;
            updateVendorDto.PhoneNumber = vendor.PhoneNumber;
            updateVendorDto.Title       = vendor.Title;
            updateVendorDto.VendorName  = vendor.VendorName;
            vendorPatch.ApplyTo(updateVendorDto);

            var responseUpdateVendorByPatch = _IVendorServices.UpdateVendorServices(updateVendorDto, id);

            if (responseUpdateVendorByPatch)
            {
                return(Ok());
            }
            else
            {
                return(StatusCode(500));
            }
        }
コード例 #3
0
        public async Task <ServiceResponse <GetVendorDto> > UpdateVendor(UpdateVendorDto req)
        {
            ServiceResponse <GetVendorDto> response = new ServiceResponse <GetVendorDto>();
            var data = await _context.Tb_vendor.FirstOrDefaultAsync(c => c.Id == req.Id);

            if (data == null)
            {
                response.Status  = false;
                response.Message = "Data Vendor tidak ditemukan";
                return(response);
            }
            data.Nama_vendor      = req.Nama_vendor;
            data.Alamat_vendor    = req.Alamat_vendor;
            data.No_telp          = req.No_telp;
            data.Penanggung_jawab = req.Penanggung_jawab;
            data.No_telp_pj       = req.No_telp_pj;
            try
            {
                _context.Tb_vendor.Update(data);
                await _context.SaveChangesAsync();

                response.Data    = _mapper.Map <GetVendorDto>(data);
                response.Message = "Berhasil Update Vendor";
            }
            catch (Exception ex)
            {
                response.Status  = false;
                response.Message = ex.Message;
            }
            return(response);
        }
コード例 #4
0
        public IActionResult UpdateVendor([FromRoute] int id, UpdateVendorDto dto)
        {
            var responseUpdateVendorByPut = _IVendorServices.UpdateVendorServicesByPut(dto, id);

            if (responseUpdateVendorByPut)
            {
                return(Ok());
            }
            else
            {
                return(StatusCode(500));
            }
        }
コード例 #5
0
        public bool UpdateVendorServicesByPut(UpdateVendorDto dto, int id)
        {
            var tags = _vendorRepository.GetTagByIdRepository(id);

            for (int i = 0; i < tags.Count; i++)
            {
                _vendorRepository.DeleteListTagsRepository(tags[i]);
            }


            List <Tag> listTag = new List <Tag>();

            for (int i = 0; i < dto.InseragDtos.Count; i++)
            {
                Tag tag = new Tag();
                tag.Name = dto.InseragDtos[i].Name;
                listTag.Add(tag);
            }


            Vendor VendorForUpdate = new Vendor();

            VendorForUpdate.Id          = id;
            VendorForUpdate.Adress      = dto.Adress;
            VendorForUpdate.Email       = dto.Email;
            VendorForUpdate.Date        = dto.Date;
            VendorForUpdate.Gender      = dto.Gender;
            VendorForUpdate.Title       = dto.Title;
            VendorForUpdate.PhoneNumber = dto.PhoneNumber;
            VendorForUpdate.VendorName  = dto.VendorName;
            VendorForUpdate.Tags        = listTag;

            int result = _vendorRepository.UpdateVendorRepository(VendorForUpdate);

            if (result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #6
0
        //    public JsonResult UpdateVendorServices(UpdateVendorDto dto , int id)
        //    {

        //     var  tags= _vendorRepository.GetTagByIdRepository(id);
        //        for (int i=0; i< tags.Count; i++)
        //        {
        //            _vendorRepository.DeleteListTagsRepository(tags[i]);
        //        }


        //        List<Tag> listTag = new List<Tag>();
        //        for (int i = 0; i < dto.InseragDtos.Count; i++)
        //        {
        //            Tag tag = new Tag();
        //            tag.Name = dto.InseragDtos[i].Name;
        //            listTag.Add(tag);
        //        }

        //        Vendor VendorForUpdate = new Vendor();
        //        VendorForUpdate.Id = id;
        //        VendorForUpdate.Adress = dto.Adress;
        //        VendorForUpdate.Email = dto.Email;
        //        VendorForUpdate.Date = dto.Date;
        //        VendorForUpdate.Gender = dto.Gender;
        //        VendorForUpdate.Title = dto.Title;
        //        VendorForUpdate.PhoneNumber = dto.PhoneNumber;
        //        VendorForUpdate.VendorName = dto.VendorName;
        //        VendorForUpdate.Tags = listTag;

        //        int result = _vendorRepository.UpdateVendorRepository(VendorForUpdate);

        //        if (result > 0)
        //        {
        //            return new JsonResult(new { HttpStatusCode = HttpStatusCode.OK });
        //        }
        //        else
        //        {
        //            return new JsonResult(new { HttpStatusCode = HttpStatusCode.InternalServerError });
        //        }

        //    }
        //}


        //public JsonResult UpdateVendorServices(string name, int id)
        //{

        //    var tags = _vendorRepository.GetTagByIdRepository(id);
        //    for (int i = 0; i < tags.Count; i++)
        //    {
        //        _vendorRepository.DeleteListTagsRepository(tags[i]);
        //    }


        //    //List<Tag> listTag = new List<Tag>();
        //    //for (int i = 0; i < dto.InseragDtos.Count; i++)
        //    //{
        //    //    Tag tag = new Tag();
        //    //    tag.Name = dto.InseragDtos[i].Name;
        //    //    listTag.Add(tag);
        //    //}
        //var vendorData =    _vendorRepository.GetVendorByIdRepository(id);
        //    vendorData.VendorName = name;
        //    vendorData.Tags = tags;
        //    //Vendor VendorForUpdate = new Vendor();
        //    //VendorForUpdate.Id = id;
        //    //VendorForUpdate.Adress = dto.Adress;
        //    //VendorForUpdate.Email = dto.Email;
        //    //VendorForUpdate.Date = dto.Date;
        //    //VendorForUpdate.Gender = dto.Gender;
        //    //VendorForUpdate.Title = dto.Title;
        //    //VendorForUpdate.PhoneNumber = dto.PhoneNumber;
        //    //VendorForUpdate.VendorName = dto.VendorName;
        //    //VendorForUpdate.Tags = listTag;

        //    int result = _vendorRepository.UpdateVendorRepository(vendorData);

        //    if (result > 0)
        //    {
        //        return new JsonResult(new { HttpStatusCode = HttpStatusCode.OK });
        //    }
        //    else
        //    {
        //        return new JsonResult(new { HttpStatusCode = HttpStatusCode.InternalServerError });
        //    }

        //}
        public JsonResult UpdateVendorServices(JsonPatchDocument <UpdateVendorDto> vendorDto, int id)
        {
            var vendor = _vendorRepository.GetVendorByIdRepository(id);

            if (vendor == null)
            {
                return(new JsonResult(new { message = "اطلاعاتی با این آیدی یافت نشد" }));
            }
            UpdateVendorDto updateVendorDto = new UpdateVendorDto();

            updateVendorDto.Adress      = vendor.Adress;
            updateVendorDto.Date        = vendor.Date;
            updateVendorDto.Email       = vendor.Email;
            updateVendorDto.Gender      = vendor.Gender;
            updateVendorDto.PhoneNumber = vendor.PhoneNumber;
            updateVendorDto.VendorName  = vendor.VendorName;

            vendorDto.ApplyTo(updateVendorDto);


            Vendor vendorUpdate = new Vendor();

            vendorUpdate.Id          = id;
            vendorUpdate.Adress      = updateVendorDto.Adress;
            vendorUpdate.Date        = updateVendorDto.Date;
            vendorUpdate.Email       = updateVendorDto.Email;
            vendorUpdate.Gender      = updateVendorDto.Gender;
            vendorUpdate.PhoneNumber = updateVendorDto.PhoneNumber;
            vendorUpdate.VendorName  = updateVendorDto.VendorName;
            vendorUpdate.Title       = updateVendorDto.Title;


            int result = _vendorRepository.UpdateVendorRepository(vendorUpdate);

            if (result > 0)
            {
                return(new JsonResult(new { HttpStatusCode = HttpStatusCode.OK }));
            }
            else
            {
                return(new JsonResult(new { HttpStatusCode = HttpStatusCode.InternalServerError, Message = "عملیات مورد نظر انجام نشد" }));
            }
        }
コード例 #7
0
ファイル: UserController.cs プロジェクト: mrpelancong/spidol
 public async Task <IActionResult> UpdateVendor([FromForm] UpdateVendorDto req)
 {
     return(Ok(await _service.UpdateVendor(req)));
 }