Beispiel #1
0
        public async Task <IActionResult> Create([Bind("Name", "GenderId", "Phone", "Address", "Email", "TreatmentDate", "BirthDay")] PatientProfile model)
        {
            if (ModelState.IsValid)
            {
                //model.CreatedOn = DateTime.Now;
                //model.UpdatedOn = DateTime.Now;
                model.NameEn         = GeneralHelper.ToAscii(model.Name);
                ViewData["GenderId"] = new SelectList(_context.Genders, "Id", "Name", model.GenderId);
                if (model.TreatmentDate.HasValue)
                {
                    model.TreatmentDate = model.TreatmentDate.Value.Add(DateTime.Now.TimeOfDay);
                }
                var id = await _profileService.AddAsync(model);

                if (id > 0)
                {
                    return(RedirectToAction("Details", new { id = model.Id }));
                }
            }
            return(View(model));
        }