private async Task saveOrderStatus(int invoiceId, string status) { invoiceStatus st = new invoiceStatus(); st.status = status; st.invoiceId = invoiceId; st.createUserId = MainWindow.userLogin.userId; st.isActive = 1; int res = await invoice.saveOrderStatus(st); if (res > 0) { Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopConfirm"), animation: ToasterAnimation.FadeIn); } else { Toaster.ShowError(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn); } }
public string Save(string token) { token = TokenManager.readToken(HttpContext.Current.Request); string message = ""; var strP = TokenManager.GetPrincipal(token); if (strP != "0") //invalid authorization { return(TokenManager.GenerateToken(strP)); } else { string statusObject = ""; invoiceStatus Object = null; IEnumerable <Claim> claims = TokenManager.getTokenClaims(token); foreach (Claim c in claims) { if (c.Type == "itemObject") { statusObject = c.Value.Replace("\\", string.Empty); statusObject = statusObject.Trim('"'); Object = JsonConvert.DeserializeObject <invoiceStatus>(statusObject, new JsonSerializerSettings { DateParseHandling = DateParseHandling.None }); break; } } try { using (incposdbEntities entity = new incposdbEntities()) { invoiceStatus tmpStatus = new invoiceStatus(); var statusEntity = entity.Set <invoiceStatus>(); if (Object.invStatusId == 0) { Object.createDate = DateTime.Now; Object.updateDate = DateTime.Now; Object.updateUserId = Object.createUserId; tmpStatus = statusEntity.Add(Object); entity.SaveChanges(); message = tmpStatus.invStatusId.ToString(); return(TokenManager.GenerateToken(message)); } else { tmpStatus = entity.invoiceStatus.Where(p => p.invStatusId == Object.invStatusId).FirstOrDefault(); tmpStatus.notes = Object.notes; tmpStatus.status = Object.status; tmpStatus.createDate = Object.createDate; tmpStatus.updateDate = Object.updateDate; tmpStatus.updateUserId = Object.updateUserId; tmpStatus.isActive = Object.isActive; tmpStatus.updateDate = DateTime.Now;// server current date; entity.SaveChanges(); message = tmpStatus.invStatusId.ToString(); return(TokenManager.GenerateToken(message)); } } } catch { message = "0"; return(TokenManager.GenerateToken(message)); } } }