public async Task <BarangResponse> AddPost(BarangRequest request, string email) { BarangResponse response = new BarangResponse(); try { TypeBarangRequest typeRequest = new TypeBarangRequest(); typeRequest.ID = request.TypeBarangId; var getTYpe = da_type.GetPost(typeRequest).Result; Barang model = new Barang(); model.HargaOtr = request.HargaOtr; model.Name = getTYpe.Model.Name; model.WarnaId = request.WarnaId; model.PhotoPath = request.PhotoPath; model.TypeBarangId = request.TypeBarangId; model.Created = DateTime.Now; model.CreatedBy = email; model.RowStatus = true; model.KotaId = request.KotaID.Value; var postId = await dep.AddPost(model); if (postId > 0) { response.Message = "Data Already Saved"; response.IsSuccess = true; } else { response.Message = "Save Failed"; response.IsSuccess = false; } } catch (Exception ex) { response.Message = ex.ToString(); response.IsSuccess = false; } return(response); }
public async Task <TypeBarangResponse> GetPost(TypeBarangRequest request) { return(await dep.GetPost(request)); }