Exemplo n.º 1
0
        public JsonResult AcknowledgeDisbursement(int id, string disbursementId, string remark)
        {
            if (String.IsNullOrEmpty(disbursementId))
            {
                return(Json(new { status = "Bad" }, JsonRequestBehavior.AllowGet));
            }
            //check if the disbursement is signed by the rep,
            //if unsigned, return bad
            //if signed,update status and disbursed by
            Disbursement d = _disbursementDAO.FindById(Int32.Parse(disbursementId));

            if (d == null)
            {
                return(Json(new { status = "Bad" }, JsonRequestBehavior.AllowGet));
            }
            else if (!d.Status.Label.Equals("Received"))
            {
                return(Json(new { status = "Bad" }, JsonRequestBehavior.AllowGet));
            }
            bool isAuth = false;

            foreach (CPClerk cpclerk in d.CollectionPoint.CPClerks)
            {
                if (cpclerk.IdStoreClerk == id)
                {
                    isAuth = true;
                }
            }
            if (isAuth == false)
            {
                return(Json(new { status = "Bad" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                _disbursementDAO.UpdateDisbursementToDisbursed(id, Int32.Parse(disbursementId));
                //send notification here
            }
            return(Json(new { status = "Ok" }, JsonRequestBehavior.AllowGet));
        }