public async Task <IActionResult> PutThankCard(long?id, ThankCard thankCard) { if (id != thankCard.Id) { return(BadRequest()); } _context.Entry(thankCard).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ThankCardExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <ThankCard> > PostThankCard(ThankCard thankCard) { _context.ThankCards.Add(thankCard); await _context.SaveChangesAsync(); return(CreatedAtAction("GetThankCard", new { id = thankCard.Id }, thankCard)); }
public List <object> updateThankCardReply(int id, string status, string reply) { List <ThankCard> thankcard = new List <ThankCard>(); var data1 = from s in _context.ThankCards where s.Id == id && s.isActive == true select s; thankcard = data1.ToList <ThankCard>(); if (thankcard.Count() > 0) { ThankCard objthank = new ThankCard(); objthank = thankcard[0]; objthank.Status = status; objthank.ReplyDate = DateTime.Now; objthank.ReplyText = reply; objthank.ts = DateTime.Now; objthank.isActive = true; _context.ThankCards.Update(objthank); _context.SaveChanges(); } data1 = from s in _context.ThankCards where s.Id == id && s.isActive == true select s; List <object> ret_thankcard = data1.ToList <object>(); return(ret_thankcard); }
public List <ThankCard> updateThankCardView(int id, string status) { List <ThankCard> thankcard = new List <ThankCard>(); var data1 = from s in _context.ThankCards where s.Id == id && s.isActive == true select s; thankcard = data1.ToList <ThankCard>(); if (thankcard.Count() > 0) { ThankCard objthank = new ThankCard(); objthank = thankcard[0]; objthank.Status = status; objthank.ts = DateTime.Now; objthank.isActive = true; _context.ThankCards.Update(objthank); _context.SaveChanges(); } data1 = from s in _context.ThankCards // join e in _context.Employees on s.From_Employee_Id equals e.Id where s.Id == id && s.isActive == true select s; List <ThankCard> ret_thankcard = data1.ToList <ThankCard>(); return(ret_thankcard); }
public string UpdateThankCardView(string paramList) { //Accepting data from var arr = JObject.Parse(paramList); int id = (int)arr["Id"]; string status = (string)arr["status"]; //Checking Data Have or Not in ThanksCards Table var thankcards = _context.ThankCards.Where(e => e.Id == id && e.isActive == true); ////Creating Objects for Json Returns IDictionary <string, List <object> > result = new Dictionary <string, List <object> >(); List <object> returndata = new List <object>(); List <object> empreturndata = new List <object>(); List <object> returnstatus = new List <object>(); ReturnData retdata = new ReturnData(); //Checking Data Have or Not in ThankCards Table if (thankcards.Count() > 0) { // Updating Row data with Client Update Data List <ThankCard> thankcardlist = _thankcardservice.updateThankCardView(id, status); // list employee data if (thankcardlist.Count() > 0) { ThankCard objcard = new ThankCard(); objcard = (ThankCard)thankcardlist[0]; List <object> fromempdata = _thankcardservice.getEmployee("%", "%", objcard.From_Employee_Id.ToString(), objcard.To_Employee_Id.ToString()); empreturndata.Add(fromempdata); result["fromEmpData"] = empreturndata; } //Return Updated Result to Client with JSON format returndata.Add(thankcardlist); retdata.statuscode = "200"; retdata.status = "Success"; returnstatus.Add(retdata); result["status"] = returnstatus; result["thankcards"] = returndata; } else { // There is no data to update retdata.statuscode = "304"; retdata.status = "No Data To Update"; returnstatus.Add(retdata); result["status"] = returnstatus; result["thankcards"] = returndata; } return(JsonConvert.SerializeObject(result)); }
public string InsertThankCard(string paramList) { var arr = JObject.Parse(paramList); int from_emp_id = (int)arr["from_emp_id"]; int to_emp_id = (int)arr["to_emp_id"]; string title = (string)arr["title"]; string send_text = (string)arr["send_text"]; string status = (string)arr["status"]; //Creating Objects for Json Returns IDictionary <string, List <object> > result = new Dictionary <string, List <object> >(); List <object> returndata = new List <object>(); List <object> returnstatus = new List <object>(); ReturnData retdata = new ReturnData(); //Accepting data comming from Client(PHP) ThankCard thankCard = new ThankCard(); thankCard.From_Employee_Id = from_emp_id; thankCard.To_Employee_Id = to_emp_id; thankCard.Title = title; thankCard.SendText = send_text; thankCard.SendDate = DateTime.Now; thankCard.ReplyDate = DateTime.Now; thankCard.ReplyText = ""; thankCard.Status = "Delivered"; thankCard.ts = DateTime.Now; thankCard.isActive = true; //Inserting data into tables ThankCard thankcardresult = _thankcardservice.CreateThankCards(thankCard); returndata.Add(thankcardresult); retdata.statuscode = "200"; retdata.status = "Success"; returnstatus.Add(retdata); result["status"] = returnstatus; result["thankcard"] = returndata; return(JsonConvert.SerializeObject(result)); }
public ThankCard CreateThankCards(ThankCard thakcard) { _context.ThankCards.Add(thakcard); _context.SaveChanges(); return(thakcard); }