public static Respone <T> Return(T data, IBorrowable <T> item, IBorrower <T> client) { Respone <T> feedback = new Respone <T>(); try { if (!item.ReturnMe(data)) { feedback.IsWorking = false; feedback.Message = "Failed: invalid data"; return(feedback); } if (!client.ReturnAt(data)) { item.BorrowMe(data); feedback.IsWorking = false; feedback.Message = "Failed: invalid data"; return(feedback); } feedback.IsWorking = true; feedback.Message = $"{item.ToString()}\nreturned succesfully by\n{client.ToString()}"; } catch (Exception e) { feedback.IsWorking = false; feedback.Message = e.Message; } return(feedback); }
/// <summary> /// 构造返回消息 /// </summary> /// <param name="request">请求消息</param> /// <param name="obj">响应对象</param> protected IMessage MakeRespone(Request request, object obj) { Respone respone = new Respone(); respone.Controller = request.Controller; respone.Action = request.Action; respone.IsSuccess = false; if (obj == null) { return(respone); } if (obj is Respone retRes) { respone.IsSuccess = retRes.IsSuccess; respone.Data = retRes.Data; respone.Message = retRes.Message; } else if (obj is IMessage megRes) { respone.Data = Any.Pack(megRes); } else { respone.IsSuccess = false; respone.Message = obj.ToString(); } return(respone); }
public override void Extract(object sender, ExtractionEventArgs e) { if (e.Response.BodyString != null) { if (e.Response.StatusCode == HttpStatusCode.OK) { var json = e.Response.BodyString; Respone r = JsonConvert.DeserializeObject <Respone>(json); if (AsHeaderValue) { e.WebTest.Context.Add(this.ContextParameterName, string.Format("Bearer {0}", r.access_token)); } else { e.WebTest.Context.Add(this.ContextParameterName, r.access_token); } e.Message = string.Format("Extracted Bearertoken into: {0}", this.ContextParameterName); e.Success = true; } else { e.Message = string.Format("Authentication failed: {0} ", e.Response.BodyString); e.Success = false; } } else { e.Message = "No response or response empty"; e.Success = false; } }
public IHttpActionResult AddLinkMailboxQuery([FromBody] JObject value) { int uid = (int)value["Uid"]; int countryId = (int)value["CountryId"]; string reviewId = value["ReviewId"].ToString(); decimal price = (decimal)value["Price"]; LinkMailboxQuery mailboxQuery = new LinkMailboxQuery { UserId = uid, State = 1, ReviewLink = reviewId, SubTime = DateTime.Now, Price = price, CountryId = countryId }; entities.LinkMailboxQuery.Add(mailboxQuery); int result = entities.SaveChanges(); if (result > 0) { return(Ok(Respone.Success("提交成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
public IHttpActionResult AddPagNoBadEvaluate([FromBody] JObject value) { int id = (int)value["UserId"]; int countryId = (int)value["CountryId"]; string asin = value["ASIN"].ToString(); decimal price = (decimal)value["Price"]; HomePagNoBadEvaluate homePag = new HomePagNoBadEvaluate { UserId = id, ASIN = asin, CountryId = countryId, State = 1, Price = price, BuyTime = DateTime.Now }; entities.HomePagNoBadEvaluate.Add(homePag); int result = entities.SaveChanges(); if (result > 0) { return(Ok(Respone.Success("购买成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
public ActionResult GetFridendInformation() { HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetcontact?r=1480564845349&seq=0&skey=@crypt_20089e09_d38ecc170f273d2db91833e793677276"); request.Method = "get"; request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0"; request.Referer = "https://wx.qq.com/"; request.Headers.Add("Cookie", "pgv_pvi=1499432960; pt2gguin=o1694675518; RK=aptzZsSyPP; ptcz=b74e1fb9d8ae59f25d51418c79b5352528aa033b0a4b849017965cf95107a9f1; wxuin=2922609112; webwxuvid=f7235d1630200f2f1f67b21cc9dfa26090cf59625838b4f781cf2ca9755bcd75d940fb7af2627b5506b3ff88f433f4b7; webwx_auth_ticket=CIsBENXploILGoABvGbBitQi5uGvukaHSAXbE98Uka4Ojs7KP/nDotPnr8FHV4d38NEni+OLWB3bGx1pstKrZH4kkErrYAlgT9aeRrZ09QM2URG2D1w4CmQukiqTNyg0JZygzlcZg+xJRU2lh0qLR06DRRxBChePL524b3FtR50H/7+TYqRZATgllbc=; mm_lang=zh_CN; MM_WX_NOTIFY_STATE=1; MM_WX_SOUND_STATE=1; pgv_si=s7972417536; wxsid=tjF6UrJ2RcvNH76H; wxloadtime=1480564533_expired; webwx_data_ticket=gSfR9g9aXZPGpInCl5dt6JCr; wxpluginkey=1480551842"); using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); // Read the content. string responseFromServer = reader.ReadToEnd(); Respone responsefronserver = JsonHelper.DeserializeToObject <Respone>(responseFromServer); foreach (var item in responsefronserver.MemberList) { if (item.VerifyFlag == 0) { context.Fridens.Add(item); } } if (context.SaveChanges() > 0) { return(Content("ok")); } } return(Content("fail")); }
// Pull Box public Respone <Box> TryPullBox(Gift gift) { Respone <Box> feedback = new Respone <Box>(); Box temp; try { if (_storage.TryPullBox(gift, out temp)) { _queueToTrash.MoveToEnd(_storage.LastUsedBox); feedback.IsWorking = true; if (temp.Quantity == 0) { feedback.Message = "This is the last box of this size in the storage!"; } else if (temp.Quantity <= FromConfig.CriticalMinBoxes) { feedback.Message = "The boxes of this size will soon end!"; } feedback.Data = temp; } else { feedback.IsWorking = false; feedback.Message = "Box not found"; } } catch (Exception e) { feedback.IsWorking = false; feedback.Message = e.Message; } return(feedback); }
public IHttpActionResult ChangeSubmenu([FromBody] JObject value) { int result = 0; int id = (int)value["Id"]; string submenuName = value["SubmenuName"].ToString(); decimal price = (decimal)value["Price"]; string remark = value["Remark"].ToString(); int state = (int)value["State"]; var query = entities.NavBySubmeun.Where(e => e.Id == id).FirstOrDefault(); if (query != null) { query.SubmenuName = submenuName; query.Price = price; query.Remark = remark; query.State = state; DbEntityEntry entry = entities.Entry(query); entry.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); } if (result > 0) { return(Ok(Respone.Success("修改成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
public IHttpActionResult AddKeyWordUpHomePag([FromBody] JObject value) { int id = (int)value["UserId"]; int countryId = (int)value["CountryId"]; string asin = value["ASIN"].ToString(); decimal price = (decimal)value["Price"]; string keyWord = value["KeyWord"].ToString(); KeyWordUpHomePag key = new KeyWordUpHomePag { UserId = id, ASIN = asin, Price = price, KeyWord = keyWord, State = 1, CountryId = countryId, SubTime = DateTime.Now }; entities.KeyWordUpHomePag.Add(key); int result = entities.SaveChanges(); if (result > 0) { return(Ok(Respone.Success("提交成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
public IHttpActionResult ChangeDrawMoenyState([FromBody] JObject value) { int result = 0; int id = (int)value["Id"]; int state = (int)value["State"]; var query = entities.DrawMoney.Where(d => d.Id == id).FirstOrDefault(); if (query != null && state == 2) { //提现成功 query.State = 2; DbEntityEntry entry = entities.Entry(query); entry.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); //日志表记录 if (result > 0) { var model = entities.AroundUserFinance.Where(c => c.UserId == query.UserId).FirstOrDefault(); if (model != null) { model.AccountBalance = model.AccountBalance - query.RemoveMoeny; model.AccumulatedExpenditure = model.AccumulatedExpenditure + query.RemoveMoeny; DbEntityEntry entry1 = entities.Entry(model); entry1.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0); AroundUserFinanceLog log = new AroundUserFinanceLog { BusinessNumber = Convert.ToInt64(ts.TotalMilliseconds).ToString(), UserId = model.UserId, PaymentState = 3, TransactionType = 1, TransactionTime = DateTime.Now, TransactionAmount = query.RemoveMoeny, Remarks = "提现支出" }; entities.AroundUserFinanceLog.Add(log); result = entities.SaveChanges(); } } } else { query.State = 3; DbEntityEntry entry = entities.Entry(query); entry.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); return(Ok(Respone.Success("提现失败"))); } if (result > 0) { return(Ok(Respone.Success("提现成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
public IHttpActionResult AddSubmenu([FromBody] JObject value) { int result = 0; int modularId = (int)value["ModularId"]; string submenuName = value["SubmenuName"].ToString(); decimal price = (decimal)value["Price"]; string remark = value["Remark"].ToString(); NavBySubmeun submenu = new NavBySubmeun { ModularId = modularId, SubmenuName = submenuName, Price = price, Remark = remark, State = 1 }; entities.NavBySubmeun.Add(submenu); result = entities.SaveChanges(); if (result > 0) { return(Ok(Respone.Success("添加成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
public IHttpActionResult ResetPassword([FromBody] JObject value) { int result = 0; int id = (int)value["Id"]; string password = value["Password"].ToString(); if (string.IsNullOrWhiteSpace(password) == true) { return(Ok(Respone.No("请输入密码"))); } else { var pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5"); var bid = entities.BackUser.Where(e => e.Id == id).FirstOrDefault(); if (bid != null) { bid.Password = pwd; DbEntityEntry entry = entities.Entry(bid); entry.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); } } if (result > 0) { return(Ok(Respone.Success("密码重置成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
public IHttpActionResult ChangeBackUserState([FromBody] JObject value) { int result = 0; int id = (int)value["Id"]; string name = value["Name"].ToString(); string phone = value["Phone"].ToString(); int state = (int)value["State"]; var bid = entities.BackUser.Where(e => e.Id == id).FirstOrDefault(); if (bid != null) { bid.State = state; bid.Name = name; bid.Phone = phone; DbEntityEntry entry = entities.Entry(bid); entry.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); } if (result > 0) { return(Ok(Respone.Success("修改成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
public IHttpActionResult AddBackUser([FromBody] JObject value) { int result = 0; string name = value["Name"].ToString(); string loginname = value["LoginName"].ToString(); string password = value["Password"].ToString(); string phone = value["Phone"].ToString(); var pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5"); var query = entities.BackUser.Where(e => e.LoginName == loginname).FirstOrDefault(); if (query != null) { return(Ok(Respone.No("该账号已存在!"))); } BackUser backUser = new BackUser(); backUser.Name = name; backUser.LoginName = loginname; backUser.Password = pwd; backUser.Phone = phone; backUser.State = 1; entities.BackUser.Add(backUser); result = entities.SaveChanges(); if (result > 0) { return(Ok(Respone.Success("添加成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
public IHttpActionResult AddRole([FromBody] JObject value) { int result = 0; string roleName = value["RoleName"].ToString(); string remarks = value["Remarks"].ToString(); var query = entities.Role.Where(e => e.RoleName == roleName).FirstOrDefault(); if (query != null) { return(Ok(Respone.No("该角色已存在!"))); } Role role = new Role(); role.RoleName = roleName; role.Remarks = remarks; entities.Role.Add(role); result = entities.SaveChanges(); if (result > 0) { return(Ok(Respone.Success("添加成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
public IHttpActionResult DeleteBadEvaluate([FromBody] JObject value) { int id = (int)value["UserId"]; string review = value["Review"].ToString(); decimal price = (decimal)value["Price"]; BadEvaluate bad = new BadEvaluate { ReviewLink = review, State = 1, //待确认 Price = price, SubTime = DateTime.Now, UserId = id }; entities.BadEvaluate.Add(bad); int result = entities.SaveChanges(); if (result > 0) { return(Ok(Respone.Success("上传成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
public IHttpActionResult UserLogin([FromBody] JObject value) { int result = 0; var phone = value["Phone"].ToString(); var password = value["Password"].ToString(); var code = value["Code"].ToString(); if (Common.Cookie.getcookie("Code").ToUpper() != code.ToUpper()) { return(Ok(Respone.No("验证码不正确"))); } var pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5"); var user = entities.AroundUser.Where(u => u.Phone == phone && u.PassWord == pwd && u.Enable == 1).FirstOrDefault(); if (user == null) { return(Ok(Respone.No("用户名或者密码错误"))); } else { System.Web.HttpContext.Current.Session["UserId"] = user.Id; return(Ok(Respone.Success(user.Id + "," + user.Name, "登录成功"))); } }
public IHttpActionResult AddDifferent([FromBody] JObject value) { int uid = (int)value["UserId"]; decimal price = (decimal)value["Price"]; int type = (int)value["Type"]; string link = value["Link"].ToString(); int estimateNumber = (int)value["EstimateNumber"]; int actualNumber = (int)value["ActualNumber"]; Different different = new Different { UserId = uid, State = 1, Type = type, Price = price, Link = link, EstimateNumber = estimateNumber, ActualNumber = actualNumber, AddTimes = DateTime.Now }; entities.Different.Add(different); int result = entities.SaveChanges(); if (result > 0) { return(Ok(Respone.Success("提交成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
// Delete unused boxes from queue and storage (return deleted boxes) public Respone <List <Box> > MoveToTrash() { Respone <List <Box> > feedback = new Respone <List <Box> >(); feedback.Data = new List <Box>(); while (!IsEmpty) { // check and delete first box in queue if in unused too long time TimeSpan unused = DateTime.Now.Subtract(_queueToTrash.PeekHead.LastUse); if (TimeSpan.Compare(unused, FromConfig.UnusingBoxMaxTime) >= 0) { feedback.Data.Add(_queueToTrash.PeekHead); _storage.Delete(_queueToTrash.Dequeue()); } else { break; // found used-box, finish checking } } // check if exist deleted boxes in respone and return status of action & message (message - if IsWork - true) if (feedback.Data.Count > 0) { feedback.IsWorking = true; feedback.Message = $"Deleted {feedback.Data.Count} unused box(es)"; } else { feedback.Data = null; feedback.IsWorking = false; } return(feedback); }
// private search-methods // by id private Respone <List <AbstractItem> > SearchById(string id) { Respone <List <AbstractItem> > feedback = new Respone <List <AbstractItem> >(); int parsedId; // check if parsing if (!int.TryParse(id, out parsedId)) { feedback.IsWorking = false; feedback.Message = "For enter ISBN / ISSN enter digits only"; feedback.WrongDataType = WrongData.ItemId; } else { if (!Exist(parsedId)) { feedback.IsWorking = false; feedback.Message = "Nothing found"; } else { feedback.Data = new List <AbstractItem>(); feedback.Data.Add(GetItem(parsedId)); feedback.IsWorking = true; } } return(feedback); }
public IHttpActionResult AddCountry([FromBody] JObject value) { int result = 0; string countryName = value["CountryName"].ToString(); string counteyShorthand = value["CounteyShorthand"].ToString(); var query = entities.Country.Where(e => e.CountryName == countryName || e.CounteyShorthand == counteyShorthand).FirstOrDefault(); if (query != null) { return(Ok(Respone.No("国家名称或简写已存在!"))); } Country country = new Country(); country.CountryName = countryName; country.CounteyShorthand = counteyShorthand; country.State = 1; entities.Country.Add(country); result = entities.SaveChanges(); if (result > 0) { return(Ok(Respone.Success("添加成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
static void Main(string[] args) { Retrofit retrofit = new Retrofit.Builder() .AddHeader("testHeader5:thisIsHeader5") .setUrl("http://localhost:21021") .build(); ILoginService service = retrofit.create <ILoginService>(); Entity.UserLoginRequestEnt ent = new Entity.UserLoginRequestEnt() { userNameOrEmailAddress = "admin", password = "******", rememberClient = true }; Call call = service.Login("admin", "123456", ent, "dynamicHeader4"); Respone <AbpCommonResponseEnt <UserLoginResponseEnt> > rep = call.Execute <AbpCommonResponseEnt <UserLoginResponseEnt> >(); //rep.IsSuccess //rep.Msg //rep.Code //rep.Data Console.WriteLine(call.Msg); Console.ReadLine(); }
public IHttpActionResult UserByAddShopCartPictureUpload() { string pric = ""; var imageName1 = HttpContext.Current.Request.Files["image"]; // 从前台获取文件 if (imageName1 != null) { string file = imageName1.FileName; string fileFormat = file.Split('.')[file.Split('.').Length - 1]; // 以“.”截取,获取“.”后面的文件后缀 //Regex imageFormat = new Regex(@"^(ZIP)|(RAR)|(7Z)|(CAB)"); // 验证文件后缀的表达式 if (string.IsNullOrEmpty(file)) // 验证后缀,判断文件是否是所要上传的格式 { pric = ""; //没有上传图片 return(Ok(Respone.No("上传文件名称不能为空"))); } else { string timeStamp = DateTime.Now.Ticks.ToString(); // 获取当前时间的string类型 string firstFileName = timeStamp.Substring(0, timeStamp.Length - 4); // 通过截取获得文件名 string imageStr = "/Images/UploadFiles/"; // 获取保存图片的项目文件夹 string uploadPath = HttpContext.Current.Server.MapPath("~/" + imageStr); // 将项目路径与文件夹合并 string pictureFormat = file.Split('.')[file.Split('.').Length - 1]; // 设置文件格式 string fileName = firstFileName + "." + fileFormat; // 设置完整(文件名+文件格式) string saveFile = uploadPath + fileName; //文件路径 imageName1.SaveAs(saveFile); // 保存文件 pric = imageStr + fileName; // 设置数据库保存图片的路径 return(Ok(Respone.Success(pric, "上传成功"))); } } pric = ""; //没有上传图片 return(Ok(Respone.No("请上传文件"))); }
public IHttpActionResult AddAsinKeyWord([FromBody] JObject value) { int id = (int)value["UserId"]; int countryId = (int)value["CountryId"]; string asin = value["ASIN"].ToString(); decimal price = (decimal)value["Price"]; AsinKeyWord asinKey = new AsinKeyWord { UserId = id, CountryId = countryId, ASIN = asin, State = 1, Price = price, BuyTime = DateTime.Now }; entities.AsinKeyWord.Add(asinKey); int result = entities.SaveChanges(); if (result > 0) { return(Ok(Respone.Success("购买成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
public IHttpActionResult AddShopReport([FromBody] JObject value) { int id = (int)value["UserId"]; int countryId = (int)value["CountryId"]; string shopEmail = value["ShopEmail"].ToString(); string shopId = value["ShopId"].ToString(); decimal price = (decimal)value["Price"]; ShopReport report = new ShopReport { UserId = id, CountryId = countryId, ShopEmail = shopEmail, ShopId = shopId, Price = price, State = 1, BuyTime = DateTime.Now }; entities.ShopReport.Add(report); int result = entities.SaveChanges(); if (result > 0) { return(Ok(Respone.Success("购买成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
// Search Journal private void searchJournBtn_Click(object sender, RoutedEventArgs e) { _feedback = _library.Search(_criteria, inputTbx.Text); if (!_feedback.IsWorking) { RefreshListBoxSearchResults(); } else { _feedback = Filter.ByType(ItemType.Journal, _feedback.Data); } if (!_feedback.IsWorking) { RefreshListBoxSearchResults(); } else { _feedback = Filter.ByGenre(_selectedGenre, _feedback.Data); } if (!_feedback.IsWorking) { RefreshListBoxSearchResults(); } else { _feedback = Filter.ByCurrentUser(_feedback.Data); } RefreshListBoxSearchResults(); }
public IHttpActionResult ResetPwd([FromBody] JObject value) { int result = 0; int id = (int)value["Id"]; string oldPassWord = value["OldPassWord"].ToString(); string newPassWord = value["NewPassWord"].ToString(); string confirmPassWord = value["ConfirmPassWord"].ToString(); if (newPassWord != confirmPassWord) { return(Ok(Respone.No("新密码不一致"))); } var pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(oldPassWord, "MD5"); var user = entities.AroundUser.Where(e => e.Id == id && e.PassWord == pwd).FirstOrDefault(); if (user == null) { return(Ok(Respone.No("原密码不正确"))); } var newpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(newPassWord, "MD5"); user.PassWord = newpwd; result = entities.SaveChanges(); if (result > 0) { return(Ok(Respone.Success("修改成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
public IHttpActionResult AddOrderMailboxQuery([FromBody] JObject value) { int uid = (int)value["UserId"]; int countryId = (int)value["CountryId"]; decimal price = (decimal)value["Price"]; string asin = value["ASIN"].ToString(); string orderNumber = value["OrderNumber"].ToString(); OrderMailboxQuery order = new OrderMailboxQuery { UserId = uid, State = 1, CountryId = countryId, Price = price, ASIN = asin, OrderNumber = orderNumber, SubTime = DateTime.Now }; entities.OrderMailboxQuery.Add(order); int result = entities.SaveChanges(); if (result > 0) { return(Ok(Respone.Success("提交成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
public IHttpActionResult ChangerNotice([FromBody] JObject value) { int result = 0; int id = (int)value["Id"]; string title = value["Titles"].ToString(); string contenting = value["Contenting"].ToString(); var nid = entities.Notice.Where(e => e.Id == id).FirstOrDefault(); if (nid != null) { nid.Title = title; nid.Contenting = contenting; DbEntityEntry entry = entities.Entry(nid); entry.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); } if (result > 0) { return(Ok(Respone.Success("修改成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
public static Respone <T> Borrow(T data, IBorrowable <T> item, IBorrower <T> client) { Respone <T> feedback = new Respone <T>(); // check if item can be borrowed and client can borrow it if (!client.IsCanBorrow) { feedback.IsWorking = false; feedback.Message = "Client can't borrow any item"; return(feedback); } if (!item.IsAvailable) { feedback.IsWorking = false; feedback.Message = "The item is not available"; return(feedback); } if (!client.IsCanBorrowAt(data)) { feedback.IsWorking = false; feedback.Message = "Client can't borrow this item"; return(feedback); } // update borrowing-data data.ItemDescription = item.ToString(); data.BorrowedSinse = DateTime.Now; // try borrow try { if (!item.BorrowMe(data)) { feedback.IsWorking = false; feedback.Message = "Failed"; return(feedback); } if (!client.BorrowAt(data)) { feedback.IsWorking = false; feedback.Message = "Failed"; item.ReturnMe(data); return(feedback); } feedback.Data = data; feedback.IsWorking = true; feedback.Message = $"{item.ToString()}\nborrowed succesfully by\n{client.ToString()}";; } catch (Exception e) { feedback.IsWorking = false; feedback.Message = e.Message; } return(feedback); }