public async Task <IActionResult> Report(SuppVM suppVM)
        {
            SuppList supps    = new SuppList();
            var      readTask = await GetSupps();

            byte[] abytes = supps.PrepareReport(readTask);
            return(File(abytes, "application/pdf", $"Supplier List{DateTime.Now.ToString("hh:mm:ss MM/dd/yyyy")}.pdf"));
        }
        public IActionResult Put(int id, SuppVM suppVM)
        {
            var put = _suppsService.Update(id, suppVM);

            if (put > 0)
            {
                return(Ok(put));
            }
            return(BadRequest("Update Failed!"));
        }
        public IActionResult Post(SuppVM suppVM)
        {
            var push = _suppsService.Create(suppVM);

            if (push > 0)
            {
                return(Ok(push));
            }
            return(BadRequest("Added Suppliers Failed!"));
        }
Beispiel #4
0
        public int Create(SuppVM suppVM)
        {
            using (SqlConnection connection = new SqlConnection(_connectionStrings.Value))
            {
                var procName = "SP_InsertSupp";                                                                 //callsp
                parameters.Add("@Name", suppVM.Name);                                                           //retrieve username

                var users = connection.Execute(procName, parameters, commandType: CommandType.StoredProcedure); //toiinputdatausingdapper
                return(users);
            }
        }
Beispiel #5
0
        public int Update(int Id, SuppVM suppVM)
        {
            using (SqlConnection connection = new SqlConnection(_connectionStrings.Value))
            {
                var procName = "SP_UpdateSupps";
                parameters.Add("@ID", Id);
                parameters.Add("@Name", suppVM.Name);

                var supps = connection.Execute(procName, parameters, commandType: CommandType.StoredProcedure); //toiinputdatausingdapper
                return(supps);
            }
        }
Beispiel #6
0
        public async Task <SuppVM> PageSearch(string keyword, int pageSize, int pageNumber)
        {
            using (SqlConnection connection = new SqlConnection(_connectionStrings.Value))
            {
                var procName = "SP_SuppPageSearch";
                parameters.Add("@SearchKey", keyword);
                parameters.Add("@pageSize", pageSize);
                parameters.Add("@pageNumber", pageNumber);
                parameters.Add("@length", dbType: DbType.Int32, direction: ParameterDirection.Output);
                parameters.Add("@filterlength", dbType: DbType.Int32, direction: ParameterDirection.Output);

                var result = new SuppVM();

                result.data = await connection.QueryAsync <SuppVM>(procName, parameters, commandType : CommandType.StoredProcedure); //await ada jeda. bermanfaat untuk banyak data

                int filterlength = parameters.Get <int>("@filterlength");
                result.filterlength = filterlength;
                int length = parameters.Get <int>("@length");
                result.length = length;
                return(result);
            }
        }
        public JsonResult InsertOrUpdate(SuppVM suppVM)
        {
            var client = new HttpClient
            {
                BaseAddress = new Uri("https://localhost:44377/api/")
            };

            client.DefaultRequestHeaders.Add("Authorization", HttpContext.Session.GetString("JWToken"));
            var myContent   = JsonConvert.SerializeObject(suppVM);
            var buffer      = System.Text.Encoding.UTF8.GetBytes(myContent);
            var byteContent = new ByteArrayContent(buffer);

            byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            if (suppVM.Id == 0)
            {
                var result = client.PostAsync("supps", byteContent).Result;
                return(Json(result));
            }
            else
            {
                var result = client.PutAsync("supps/" + suppVM.Id, byteContent).Result;
                return(Json(result));
            }
        }
Beispiel #8
0
 public int Update(int Id, SuppVM suppVM)
 {
     return(_suppRepository.Update(Id, suppVM));
 }
Beispiel #9
0
 public int Create(SuppVM suppVM)
 {
     return(_suppRepository.Create(suppVM));
 }
Beispiel #10
0
 public void Delete(SuppVM suppVM)
 {
     this.DeleteDate = DateTimeOffset.Now;
     this.isDelete   = true;
 }
Beispiel #11
0
 public void Update(SuppVM suppVM)
 {
     this.Name       = suppVM.Name;
     this.UpdateDate = DateTimeOffset.Now;
 }
Beispiel #12
0
 public Supp(SuppVM suppVM)
 {
     this.Name       = suppVM.Name;
     this.CreateDate = DateTimeOffset.Now;
     this.isDelete   = false;
 }