private IdentityCurrency ExtractCreateFormData(CurrencyCreateModel formData)
        {
            var myIdetity = new IdentityCurrency();

            myIdetity.Name   = formData.Name;
            myIdetity.Code   = formData.Code;
            myIdetity.Status = formData.Status;

            return(myIdetity);
        }
Example #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static Currency ToEntity(this CurrencyCreateModel model)
 {
     return(new Currency
     {
         Name = model.Name,
         Country = model.Country,
         IsoCode = model.Code.IsoCodeValue.ToUpperInvariant(),
         IsoNumber = model.IsoNumber
     });
 }
        public ActionResult Create(CurrencyCreateModel model)
        {
            var newId = 0;

            if (!ModelState.IsValid)
            {
                string messages = string.Join("; ", ModelState.Values
                                              .SelectMany(x => x.Errors)
                                              .Select(x => x.ErrorMessage + x.Exception));
                this.AddNotification(messages, NotificationType.ERROR);
                return(View(model));
            }

            try
            {
                //Extract info
                var info = ExtractCreateFormData(model);

                newId = _mainStore.Insert(info);

                //Clear cache
                CachingHelpers.ClearCurrencyCache();

                if (newId > 0)
                {
                    this.AddNotification(ManagerResource.LB_INSERT_SUCCESS, NotificationType.SUCCESS);
                }
                else
                {
                    this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR);
                }
            }
            catch (Exception ex)
            {
                this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR);

                logger.Error("Failed for Create Currency request: " + ex.ToString());

                return(View(model));
            }

            return(RedirectToAction("Edit/" + newId));
        }
        public ActionResult Create()
        {
            var createModel = new CurrencyCreateModel();

            return(View(createModel));
        }