Example #1
0
 public static Shedule ToEntity(this SheduleModel shedule)
 {
     return(new Shedule
     {
         SheduleId = shedule.Id,
         Day = shedule.Day,
         StartAM = shedule.StartAM,
         EndAM = shedule.EndAM,
         StartPM = shedule.StartPM,
         EndPM = shedule.EndPM,
         InformationId = shedule.InformationId
     });
 }
        public async Task <ActionResult> Create([Bind("Type", "Name", "VatNumber", "EmailAddress", "Description")] SheduleModel task)
        {
            try
            {
                var content      = JsonConvert.SerializeObject(task);
                var httpResponse = await Client.PostAsync(BaseUrl, new StringContent(content, Encoding.Default, "application/json"));

                if (!httpResponse.IsSuccessStatusCode)
                {
                    throw new Exception("Cannot create this Shedule !");
                }

                TempData["Message"] = "This Shedule is create successfully !";
                return(RedirectToAction("Index"));
            }

            catch (Exception ex)
            {
                TempData["Message"] = ex.Message;
                return(View("NotFound"));
            }
        }
        public async Task <ActionResult> Delete([Bind("Id", "Day", "StartAM", "EndAM", "StartPM", "EndPM", "InformationId")] SheduleModel task)
        {
            try
            {
                var httpResponse = await Client.DeleteAsync($"{BaseUrl}/{task.Id}");

                if (!httpResponse.IsSuccessStatusCode)
                {
                    throw new Exception("Cannot retieve tasks");
                }

                TempData["Message"] = "This Idendification was delete successfully !";

                return(RedirectToAction("Index"));
            }

            catch (Exception ex)
            {
                TempData["Message"] = ex.Message;
                return(View("NotFound"));
            }
        }
        public async Task <ActionResult> Edit([Bind("Day", "StartAM", "EndAM", "StartPM", "EndPM", "InformationId")] SheduleModel task)
        {
            try
            {
                var content = JsonConvert.SerializeObject(task);

                var httpResponse = await Client.PutAsync($"{BaseUrl}/{task.Id}", new StringContent(content, Encoding.Default, "application/json"));

                if (!httpResponse.IsSuccessStatusCode)
                {
                    throw new Exception("Cannot Edit this Shedule !");
                }

                TempData["Message"] = "This Shedule was update successfully !";

                return(RedirectToAction("Index"));
            }

            catch (Exception ex)
            {
                TempData["Message"] = ex.Message;
                return(View("NotFound"));
            }
        }
Example #5
0
 // POST: api/Shedule
 public void Post([FromBody] SheduleModel value)
 {
     SheduleLogic.AddShedule(SheduleControllerMapper.Map <SheduleModel, SheduleDTO>(value));
 }
Example #6
0
 public void Put(int id, [FromBody] SheduleModel value)
 {
     value.Id = id;
     SheduleLogic.Update(SheduleControllerMapper.Map <SheduleModel, SheduleDTO>(value));
 }