// GET: Treatment/Create
        public ActionResult AutoTextCreate(int?Id)
        {//10/10/2019 aakansha
            ViewBag.FormName = "AutoText";
            var model = new AutoTextModel();

            if (Id == 0)
            {
                PrepareCommentTypeDataModel(model);
                return(View(model));
            }
            else
            {
                var data = _treatmentServices.GetAutoTextById((int)Id);
                model.CreatedOn     = data.CreatedOn;
                model.Deleted       = data.Deleted;
                model.CommentTypeId = data.CommentTypeId;
                model.AutoTextName  = data.AutoTextName;
                model.Comment       = data.Comment;
                model.Id            = data.Id;
                model.IsActive      = data.IsActive;
                model.LastUpdated   = data.LastUpdated;
                PrepareCommentTypeDataModel(model);
                AddNotification(NotificationMessage.TitleSuccess, NotificationMessage.msgAddAutoText, NotificationMessage.TypeSuccess);
                return(View(model));
            }
        }
        protected virtual void PrepareCommentTypeDataModel(AutoTextModel model)
        {
            model.AvailableComments.Add(new SelectListItem {
                Text = "Select Comment", Value = "0"
            });

            foreach (var c in _treatmentServices.GetAllCommentType())
            {
                model.AvailableComments.Add(new SelectListItem
                {
                    Text     = c.CommentTypeName,
                    Value    = c.Id.ToString(),
                    Selected = c.Id == model.Id
                });
            }
        }
        public ActionResult AutoTextCreate(AutoTextModel model)
        {
            try
            {//10/10/2019 aakansha
                ViewBag.FormName = "AutoText";
                if (model.Id == 0)
                {
                    //General Data
                    var data = new AutoText();

                    data.CreatedOn     = model.CreatedOn;
                    data.Deleted       = model.Deleted;
                    data.CommentTypeId = model.CommentTypeId;
                    data.Comment       = model.Comment;
                    data.AutoTextName  = model.AutoTextName;
                    data.IsActive      = model.IsActive;
                    data.LastUpdated   = model.LastUpdated;
                    _treatmentServices.InsertAutoText(data);
                    AddNotification(NotificationMessage.TitleSuccess, NotificationMessage.msgAddAutoText, NotificationMessage.TypeSuccess);
                    return(RedirectToAction("AutoTextIndex"));
                }
                else
                {
                    var data = _treatmentServices.GetAutoTextById((int)model.Id);

                    data.CreatedOn     = model.CreatedOn;
                    data.Deleted       = model.Deleted;
                    data.CommentTypeId = model.CommentTypeId;
                    data.Comment       = model.Comment;
                    data.AutoTextName  = model.AutoTextName;
                    data.IsActive      = model.IsActive;
                    data.LastUpdated   = model.LastUpdated;
                    data.Id            = model.Id;
                    _treatmentServices.UpdateAutoText(data);
                    AddNotification(NotificationMessage.TitleSuccess, NotificationMessage.msgAddAutoText, NotificationMessage.TypeSuccess);
                    return(RedirectToAction("AutoTextIndex"));
                }
            }
            catch
            {
                AddNotification(NotificationMessage.TitleError, NotificationMessage.ErrorMsg, NotificationMessage.TypeError);
                return(View());
            }
        }