Ejemplo n.º 1
0
        public IActionResult CustomerEdit([FromRoute] int id)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                AppointDom uptmodel = new AppointDom();
                uptmodel = _svc.GetById(id);

                if (uptmodel == null)
                {
                    return(NotFound());
                }
                //seperate date
                string res1 = uptmodel.Appoint.ToString("yyyy-MM-dd");
                string res2 = uptmodel.Appoint.ToString("HH:mm");

                //build model
                CustomerEditModel model = new CustomerEditModel();
                model.Id           = uptmodel.Id;
                model.UserId       = uptmodel.UserId;
                model.CustFName    = uptmodel.CustFName;
                model.CustLName    = uptmodel.CustLName;
                model.Street       = uptmodel.Street;
                model.City         = uptmodel.City;
                model.State        = uptmodel.State;
                model.Zip          = uptmodel.Zip;
                model.Email        = uptmodel.Email;
                model.Phone        = uptmodel.Phone;
                model.AppointDate  = res1;
                model.AppointTime  = res2;
                model.ModifiedBy   = uptmodel.ModifiedBy;
                model.IsCnfrmed    = uptmodel.IsCnfrmed;
                model.ReminderSent = uptmodel.ReminderSent;
                model.CompName     = uptmodel.CompName;
                model.CompEmail    = uptmodel.CompEmail;

                return(View(model));
            }
            catch (Exception ex)
            {
                return(StatusCode(457, ex));
            }
        }
        public IActionResult GetById(int id)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                DataResponse <AppointDom> resp = new DataResponse <AppointDom>();
                resp.Data = _svc.GetById(id);

                if (resp == null)
                {
                    return(NotFound());
                }
                return(Ok(resp));
            }
            catch (System.Exception)
            {
                return(StatusCode(417, "Bullshit"));
            }
        }