Esempio n. 1
0
        public async Task <ActionResult> Edit([Bind(Include = "Id, CustomerId, HaulierCode, Name, ContactPerson, Telephone, MobileNo, EmailAddress, Website, IsActive, DateCreated, CreatedBy")] HaulierViewModel obj)
        {
            obj.UpdatedBy = CookieHelper.EmailAddress;

            var url      = "api/haulier/update";
            var response = await HttpClientHelper.ApiCall(url, Method.PUT, obj);

            if (response.StatusCode == HttpStatusCode.Forbidden)
            {
                TempData["Message"]      = obj.HaulierCode + " is already exist! Please check and try again.";
                TempData["MessageAlert"] = "warning";
                return(RedirectToAction("Index"));
            }

            if (response.IsSuccessful)
            {
                TempData["Message"]      = obj.Name + " successfully updated!";
                TempData["MessageAlert"] = "success";
                Log.Error(string.Format(Type.GetType(typeof(HaulierController).Name) + "||Update||Location ID::{0}||API Response::{1}", obj.Id, response));
                return(RedirectToAction("Index"));
            }
            else
            {
                Error("An error has occurred");
                Log.Error(string.Format(Type.GetType(typeof(HaulierController).Name) + "||Update||Location ID::{0}||API Response::{1}", obj.Id, response));
                return(PartialView(obj));
            }
        }
Esempio n. 2
0
        // GET: Haulier/Details/5
        public async Task <ActionResult> Details(long?id)
        {
            var obj      = new HaulierViewModel();
            var url      = "api/haulier/getbyid/" + id;
            var response = await HttpClientHelper.ApiCall(url, Method.GET);

            if (response.IsSuccessful)
            {
                var result = response.Content;
                var data   = JsonConvert.DeserializeObject <dynamic>(result);

                obj = new HaulierViewModel
                {
                    Id            = data.Id,
                    CustomerId    = data.CustomerId,
                    HaulierCode   = data.HaulierCode,
                    Name          = data.Name,
                    ContactPerson = data.ContactPerson,
                    Telephone     = data.Telephone,
                    MobileNo      = data.MobileNo,
                    EmailAddress  = data.EmailAddress,
                    Website       = data.Website,
                    IsActive      = data.IsActive,
                    DateCreated   = data.DateCreated,
                    CreatedBy     = data.CreatedBy,
                };
            }

            return(PartialView(obj));
        }
Esempio n. 3
0
        // GET: Haulier/Create
        public ActionResult Create()
        {
            var obj = new HaulierViewModel()
            {
                CustomerId = int.Parse(CookieHelper.CustomerId)
            };

            return(PartialView(obj));
        }