public static AdjustmentModel GetAdjustmentRaisedBy(string token, int raisedby, out string error) { string url = APIHelper.Baseurl + "/adjustment/raisedby" + raisedby; AdjustmentModel adm = APIHelper.Execute <AdjustmentModel>(token, url, out error); return(adm); }
public static AdjustmentModel GetAdjustmentbyAdjId(string token, int adjid, out string error) { string url = APIHelper.Baseurl + "/adjustment/" + adjid; AdjustmentModel adm = APIHelper.Execute <AdjustmentModel>(token, url, out error); return(adm); }
public static AdjustmentModel GetAdjustmentByDate(string token, DateTime date, out string error) { string url = APIHelper.Baseurl + "/adjustment/issuedate/" + date; AdjustmentModel adm = APIHelper.Execute <AdjustmentModel>(token, url, out error); return(adm); }
public static int SaveAdjustmentModel(AdjustmentModel adjustmentModel, string Mode) { string strExecution = "[fwd].[uspManageAdvAdj]"; int result = 0; using (DbQuery oDq = new DbQuery(strExecution)) { oDq.AddVarcharParam("@Mode", 1, Mode); oDq.AddIntegerParam("@pk_AdvAdjID", adjustmentModel.AdjustmentPk); oDq.AddIntegerParam("@fk_CompanyID", adjustmentModel.CompanyID); oDq.AddIntegerParam("@fk_JobID", Convert.ToInt32(adjustmentModel.JobNo)); oDq.AddVarcharParam("@DorC", 1, adjustmentModel.DOrC); oDq.AddIntegerParam("@fk_PartyID", Convert.ToInt32(adjustmentModel.DebtorOrCreditorName)); oDq.AddVarcharParam("@AdjustmentNo", 60, adjustmentModel.AdjustmentNo); oDq.AddDateTimeParam("@AdjustmentDate", adjustmentModel.AdjustmentDate); oDq.AddIntegerParam("@AdvanceID", adjustmentModel.AdvanceID); // oDq.AddVarcharParam("@Adjustments", int.MaxValue, Utilities.Utilities.ConvertDTOToXML<InvoiceJobAdjustment>("Root", "Adjustment", adjustmentModel.LstInvoiceJobAdjustment)); oDq.AddVarcharParam("@Adjustments", int.MaxValue, Utilities.GeneralFunctions.SerializeWithXmlTag(adjustmentModel.LstInvoiceJobAdjustment).Replace("?<?xml version=\"1.0\" encoding=\"utf-16\"?>", "")); oDq.AddIntegerParam("@UserID", adjustmentModel.UserID); oDq.AddIntegerParam("@Result", result, QueryParameterDirection.Output); var pk_AdvAdjInvID = Convert.ToInt32(oDq.GetScalar()); result = Convert.ToInt32(oDq.GetParaValue("@Result")); } return(result); }
/// <summary> /// Lambda to fetch character by name from character table /// </summary> /// <param name="pRequest">Incoming API Gateway request object, used to pull parameter from url</param> /// <param name="pContext">Incoming Lambda Context object, not used currently</param> /// <returns></returns> public APIGatewayProxyResponse FunctionHandler(APIGatewayProxyRequest pRequest, ILambdaContext pContext) { if (pRequest.Headers.Keys.Contains("warmup")) { return(HttpHelper.WarmupResponse()); } var vResponse = HttpHelper.HandleError("[GetAdjustmentsById] Unknown Backend error", 500); try { if (pRequest != null && pRequest.PathParameters != null && pRequest.PathParameters.Count > 0) { //We need to retrieve the ClientId for multitenancy purposes var vClientId = pRequest.Headers["clientid"]; int vId = int.Parse(pRequest.PathParameters["id"]); using (opendkpContext vDatabase = new opendkpContext()) { var vResult = vDatabase.Adjustments .Include("IdCharacterNavigation") .First(x => x.ClientId.Equals(vClientId) && x.IdAdjustment == vId); var vAdjustment = new AdjustmentModel(vResult); vResponse = HttpHelper.HandleResponse(vAdjustment, 200, true); } } } catch (Exception vException) { vResponse = HttpHelper.HandleError(string.Format("[GetAdjustmentsById] {0}", vException.Message), 500); } return(vResponse); }
public static AdjustmentModel UpdateAdjustment(string token, AdjustmentModel ajm, out string error) { error = ""; string url = APIHelper.Baseurl + "/adjustment/update"; string objectstring = JsonConvert.SerializeObject(ajm); ajm = APIHelper.Execute <AdjustmentModel>(token, objectstring, url, out error); return(ajm); }
public IHttpActionResult CreateAdjustment(AdjustmentModel adj) { string error = ""; AdjustmentModel adjm = AdjustmentRepo.CreateAdjustment(adj, out error); if (error != "" || adjm == null) { return(Content(HttpStatusCode.BadRequest, error)); } return(Ok(adjm)); }
// Convert From Auto Generated DB Model to APIModel private static AdjustmentModel ConvertDBtoAPIAdjust(adjustment adj) { List <AdjustmentDetailModel> adjdm = new List <AdjustmentDetailModel>(); foreach (adjustmentdetail adjd in adj.adjustmentdetails) { adjdm.Add(new AdjustmentDetailModel(adjd.adjid, adjd.itemid, adjd.item.description, adjd.adjustedqty, adjd.reason, adjd.item.category.name, adjd.item.uom)); } AdjustmentModel adjm = new AdjustmentModel(adj.adjid, adj.raisedby, adj.user.fullname, adj.raisedto, adj.user1.fullname, adj.issueddate, adj.status, adjdm); return(adjm); }
public ActionResult HistoryDetail(int id) { AdjustmentModel ajm = new AdjustmentModel(); try { List <AdjustmentModel> adjlist = TempData["history"] as List <AdjustmentModel>; ajm = adjlist.Where(x => x.Adjid == id).FirstOrDefault(); ViewBag.adjustment = ajm; } catch (Exception ex) { RedirectToAction("Index", "Error", new { error = ex.Message }); } return(View(ajm.Adjds)); }
public IHttpActionResult GetAdjustmentbyAdjId(int adjid) { string error = ""; AdjustmentModel adj = AdjustmentRepo.GetAdjustmentByID(adjid, out error); if (error != "" || adj == null) { if (error == ConError.Status.NOTFOUND) { return(Content(HttpStatusCode.NotFound, "Adjustment Not Found")); } return(Content(HttpStatusCode.BadRequest, error)); } return(Ok(adj)); }
public IHttpActionResult UpdateAdjustment(AdjustmentModel adj) { string error = ""; AdjustmentModel adjm = AdjustmentRepo.UpdateAdjustment(adj, out error); if (error != "" || adjm == null) { if (error == ConError.Status.NOTFOUND) { return(Content(HttpStatusCode.NotFound, "Adjustment Not Found")); } return(Content(HttpStatusCode.BadRequest, error)); } return(Ok(adjm)); }
public ActionResult Approve(int id) { string token = GetToken(); try { AdjustmentModel adj = APIAdjustment.GetAdjustmentbyAdjId(token, id, out string error); adj.Status = ConAdjustment.Active.APPROVED; APIAdjustment.UpdateAdjustment(token, adj, out error); } catch (Exception ex) { RedirectToAction("Index", "Error", new { error = ex.Message }); } return(RedirectToAction("Approve")); }
public List <WCFInventoryAdjustmentDetailModel> AdjustmentDetailList(string id) { List <WCFInventoryAdjustmentDetailModel> rd = new List <WCFInventoryAdjustmentDetailModel>(); List <Adjustment_Details> adjList = work.GetViewAdjustmentDetailList(id); List <AdjustmentModel> modelList = new List <AdjustmentModel>(); foreach (Adjustment_Details i in adjList) { AdjustmentModel model = new AdjustmentModel(i); modelList.Add(model); } foreach (AdjustmentModel s in modelList) { WCFInventoryAdjustmentDetailModel item = new WCFInventoryAdjustmentDetailModel(s.CatName, s.QuantityAdjusted.ToString(), s.CostAdjusted.ToString(), s.Reason); rd.Add(item); } return(rd); }
//find Adjusment by id public static AdjustmentModel GetAdjustmentByID(int adjid, out string error) { LUSSISEntities entities = new LUSSISEntities(); error = ""; adjustment adj = new adjustment(); AdjustmentModel adjm = new AdjustmentModel(); try { adj = entities.adjustments.Where(a => a.adjid == adjid).FirstOrDefault <adjustment>(); adjm = ConvertDBtoAPIAdjust(adj); } catch (NullReferenceException) { error = ConError.Status.NOTFOUND; } catch (Exception e) { error = e.Message; } return(adjm); }
//Create new Adjustment public static AdjustmentModel CreateAdjustment(AdjustmentModel adjm, out string error) { error = ""; LUSSISEntities entities = new LUSSISEntities(); adjustment adj = new adjustment(); try { adj.raisedby = adjm.Raisedby; adj.issueddate = adjm.Issueddate; adj.status = ConAdjustment.Active.PENDING; List <AdjustmentDetailModel> adjds = adjm.Adjds; //check item price foreach (AdjustmentDetailModel adjd in adjds) { adj.raisedto = 0; SupplierItemModel supp = SupplierItemRepo.GetSupplierItemByItemId(adjd.Itemid, out error); double? price = Math.Abs((Int32)adjd.Adjustedqty) * supp.Price; //Check total price of each item to consider who to report to if (price >= ConAdjustment.Active.REPORTMANAGER) { user user = entities.users.Where(u => u.role == ConUser.Role.MANAGER).First(); adj.raisedto = user.userid; } else { user user = entities.users.Where(u => u.role == ConUser.Role.SUPERVISOR).First(); adj.raisedto = user.userid; } } adj = entities.adjustments.Add(adj); entities.SaveChanges(); foreach (AdjustmentDetailModel adjdm in adjds) { adjustmentdetail adjd = new adjustmentdetail { adjid = adj.adjid, itemid = adjdm.Itemid, adjustedqty = adjdm.Adjustedqty, reason = adjdm.Reason }; adjd = entities.adjustmentdetails.Add(adjd); entities.SaveChanges(); } adjm = GetAdjustmentByID(adj.adjid, out error); NotificationModel nom = new NotificationModel(); nom.Deptid = DepartmentRepo.GetDepartmentByUserid(adj.raisedto ?? default(int), out error).Deptid; nom.Role = UserRepo.GetUserByUserID(adj.raisedto ?? default(int)).Role; nom.Title = "New Adjustment"; nom.NotiType = ConNotification.NotiType.Adjustment; nom.ResID = adj.adjid; nom.Remark = "A new adjustment has been raised by clerk!"; nom = NotificationRepo.CreatNotification(nom, out error); } catch (NullReferenceException) { error = ConError.Status.NOTFOUND; } catch (Exception e) { error = e.Message; } return(adjm); }
public int SaveAdjustmentModel(AdjustmentModel adjustmentModel, string Mode) { return(AdvAdjustmentDAL.SaveAdjustmentModel(adjustmentModel, Mode)); }
//Update Adjustment public static AdjustmentModel UpdateAdjustment(AdjustmentModel adjm, out string error) { error = ""; LUSSISEntities entities = new LUSSISEntities(); NotificationModel nom = new NotificationModel(); adjustment adj = new adjustment(); try { adj = entities.adjustments.Where(a => a.adjid == adjm.Adjid).First <adjustment>(); adj.raisedby = adjm.Raisedby; adj.raisedto = adjm.Raisedto; adj.issueddate = adjm.Issueddate; adj.status = adjm.Status; nom.Remark = "The Adjustment Voucher has been Rejected!"; if (adj.status == ConAdjustment.Active.APPROVED) { nom.Remark = "The Adjustment Voucher has been Approved!"; } List <AdjustmentDetailModel> adjustds = AdjustmentDetailRepo.GetAdjustmentDetailByAdjID(adj.adjid, out error); foreach (AdjustmentDetailModel adjustd in adjustds) { InventoryModel inventm = InventoryRepo.GetInventoryByItemid(adjustd.Itemid, out error); inventory invent = entities.inventories.Where(i => i.invid == inventm.Invid).First <inventory>(); invent.stock += adjustd.Adjustedqty; InventoryTransactionModel invtm = new InventoryTransactionModel(); invtm.InvID = invent.invid; invtm.ItemID = invent.itemid; invtm.Qty = adjustd.Adjustedqty; invtm.TransType = ConInventoryTransaction.TransType.ADJUSTMENT; invtm.TransDate = DateTime.Now; invtm.Remark = adjustd.Reason; invtm = InventoryTransactionRepo.CreateInventoryTransaction(invtm, out error); } entities.SaveChanges(); adjm = GetAdjustmentByID(adj.adjid, out error); nom.Deptid = DepartmentRepo.GetDepartmentByUserid(adj.raisedto ?? default(int), out error).Deptid; nom.Role = UserRepo.GetUserByUserID(adj.raisedby ?? default(int)).Role; nom.Title = "Adjustment Approval"; nom.NotiType = ConNotification.NotiType.Adjustment; nom.ResID = adj.adjid; nom = NotificationRepo.CreatNotification(nom, out error); } catch (NullReferenceException) { error = ConError.Status.NOTFOUND; } catch (Exception e) { error = e.Message; } return(adjm); }