Beispiel #1
0
        public async Task <IActionResult> DeleteErrorConfirmed(int id, int ColleagueID)
        {
            try
            {
                await colleages.DeleteErrorAsync(id);

                await colleages.saveAsync();
            }
            catch (Exception ex)
            {
                ViewBag.err = ex;
                return(View("Error"));
            }
            return(RedirectToAction("Colleague", "Detials", new { id = ColleagueID }));
        }
        public async Task <IActionResult> Create([Bind("ColleagueID,Name,PhoneNumber,code,color,isMale")] Colleague colleague,
                                                 IFormFile profile, string BirthDay, string StartActivity)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    colleague.BirthDay      = Convert.ToDateTime(BirthDay.ToAD());
                    colleague.StartActivity = Convert.ToDateTime(StartActivity.ToAD());
                }
                catch (Exception)
                {
                    this.SetViewMessage("Please Complete fields ...", WebMessageType.Warning);
                    return(RedirectToAction("Colleagues", "Home"));
                }

                saveProfile(ref colleague, profile);

                try
                {
                    await colleagues.InsertAsync(colleague);

                    await colleagues.saveAsync();

                    this.SetViewMessage("New Colleague Created successfully.", WebMessageType.Success);
                }
                catch (Exception ex)
                {
                    this.SetViewMessage(ex.Message, WebMessageType.Danger);
                }
            }
            else
            {
                this.SetViewMessage("Please Complete fields ...", WebMessageType.Warning);
            }
            return(RedirectToAction("Colleagues", "Home"));
        }