Example #1
0
 private void AddResultMessage(string message, bool hasErrors, ResultCode resultCode)
 {
     HasErrors = hasErrors;
     ResultMessages.Add(new ResultMessage {
         Message = message, MessageType = resultCode.ToString().ToLowerInvariant()
     });
 }
Example #2
0
        public IActionResult Login([FromBody] LoginModel model)
        {
            var user = _userService.GetByUsername(model.Username);

            if (user != null)
            {
                if (BCrypt.Net.BCrypt.Verify(model.Password, user.Password))
                {
                    var tokenHandler    = new JwtSecurityTokenHandler();
                    var key             = Encoding.ASCII.GetBytes(_appSettings.Secret);
                    var tokenDescriptor = new SecurityTokenDescriptor
                    {
                        Subject = new ClaimsIdentity(new Claim[]
                        {
                            new Claim(ClaimTypes.Name, user.Username)
                        }),
                        Expires            = DateTime.UtcNow.AddDays(7),
                        SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature)
                    };
                    var token = tokenHandler.CreateToken(tokenDescriptor);
                    return(Ok(ResultMessages.Bearer(tokenHandler.WriteToken(token))));
                }
            }
            return(Unauthorized(ResultMessages.User_Login_Invalid));
        }
Example #3
0
        // GET: /scheme/Create
        public ActionResult Create()
        {
            ResultMessages <schemeViewModel> result = null;

            try
            {
                result = new ResultMessages <schemeViewModel>(true, string.Empty);
                var routes = _routesService.GetQueryable(x => x.Id != null);
                ViewBag.routes       = new SelectList(routes.ToList(), "Id", "Name");
                ViewData["RoutesId"] = ViewBag.routes;

                var fees = _feesService.GetQueryable(x => x.Id != null);
                ViewBag.fees = new SelectList(fees.ToList(), "Id", "Name");

                var channels = _channelsService.GetQueryable(x => x.Id != null);
                ViewBag.channels = new SelectList(channels.ToList(), "Id", "Name");

                var trans = _transTypeService.GetQueryable(x => x.Id != null);
                ViewBag.trans = new SelectList(trans.ToList(), "Id", "Name");
            }
            catch (Exception ex)
            {
                result = new ResultMessages <schemeViewModel>(false, ex.Message);
            }
            return(View(result));
        }
Example #4
0
        public ActionResult Create(ProfileViewModel profileViewCreate)
        {
            GroupPermissions(profileViewCreate);
            if (!ModelState.IsValid)
            {
                return(View(profileViewCreate));
            }

            List <string> errors = _profileAppService.Insert(profileViewCreate);

            if (errors?.Count > 0)
            {
                if (errors.Contains(CodLogErrorEnum.CODELOGERROR.ToString()))
                {
                    this.Flash("Error", ResultMessages.AplicationException());
                }
                else
                {
                    AddModelStateError(errors);
                    return(View(profileViewCreate));
                }
            }
            else
            {
                this.Flash("Success", ResultMessages.Success());
            }

            return(RedirectToAction("Index"));
        }
Example #5
0
        public ActionResult Edit(UserViewModel user)
        {
            FulFillList(user);
            if (!ModelState.IsValid)
            {
                return(View(user));
            }
            user.Cpf = Formatter.RemoveFormattingOfCnpjOrCpf(user.Cpf);

            List <string> errors = _userAppService.UpdateProfile(user);

            if (errors?.Count > 0)
            {
                if (errors.Contains(CodLogErrorEnum.CODELOGERROR.ToString()))
                {
                    this.Flash("Error", ResultMessages.AplicationException());
                }
                else
                {
                    foreach (string error in errors)
                    {
                        ModelState.AddModelError(string.Empty, error);
                    }
                    return(View(user));
                }
            }
            else
            {
                this.Flash("Success", ResultMessages.Success());
            }

            return(RedirectToAction("Index"));
        }
Example #6
0
 public new IResult <TEntity> AddMessage(string message)
 {
     if (!string.IsNullOrWhiteSpace(message))
     {
         ResultMessages.Add(message);
     }
     return(this);
 }
Example #7
0
        public RequestResult(ns3QuittungTyp quittung, bool isLocalResult = false)
            : this(isLocalResult)
        {
            RequestProcessed = quittung.AnfrageBearbeitet;
            foreach (ns3QuittungTypHinweis hinweis in quittung.Hinweise)
            {
                ResultMessages.Add(new RequestResultMessage(hinweis));
            }

            CreationTime = DateTime.Now;
        }
        static public bool ValidateSolution(ref ResultMessages messages, string solutionName, IFileSystem fileSystem)
        {
            // check if *.appiosln file exists
            var solutionFullName = solutionName + Constants.FileExtension.Appiosln;

            if (string.IsNullOrEmpty(solutionName) || !fileSystem.FileExists(solutionFullName))
            {
                messages.LoggerMessage = LoggingText.SlnAppioslnFileNotFound;
                messages.OutputMessage = string.Format(OutputText.SlnAppioslnNotFound, solutionFullName);
                return(false);
            }

            return(true);
        }
Example #9
0
        public static String ToString(ResultMessages rm)
        {
            switch (rm)
            {
                case ResultMessages.REQUEST_INVALID_PARAMETER:
                    return "Request: invalid parameter entered.";

                case ResultMessages.RESPONSE_NO_DATA_FOUND:
                    return "Response: no data found.";

                case ResultMessages.RESPONSE_INVALID_PASSWORD:
                    return "Response: Invalid password.";
            }
            return "unknown result messages.";
        }
Example #10
0
        public static String ToString(ResultMessages rm)
        {
            switch (rm)
            {
            case ResultMessages.REQUEST_INVALID_PARAMETER:
                return("Request: invalid parameter entered.");

            case ResultMessages.RESPONSE_NO_DATA_FOUND:
                return("Response: no data found.");

            case ResultMessages.RESPONSE_INVALID_PASSWORD:
                return("Response: Invalid password.");
            }
            return("unknown result messages.");
        }
Example #11
0
        public JsonResultMessage UpdateRestaurant(Restaurant restaurant)
        {
            var result = ResultMessages.JsonResultMessage();

            try
            {
                _unitOfWork.Repository <Restaurant>().Update(restaurant);
                _unitOfWork.Commit();
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = "Error updating config. " + ex.Message;
            }
            return(result);
        }
Example #12
0
        public JsonResult UpdateSelectedRows(string selectedRestaurants)
        {
            var resultMessage = ResultMessages.JsonResultMessage();

            resultMessage.Message = "Successfully Updated Config";
            resultMessage.Success = true;
            try
            {
                ICollection <Restaurant> updateRestaurants = JsonConvert.DeserializeObject <ICollection <Restaurant> >(selectedRestaurants);
                var failures  = 0;
                var successes = 0;
                var result    = resultMessage;
                foreach (Restaurant restaurant in updateRestaurants)
                {
                    try
                    {
                        result = _restaurantManager.UpdateRestaurant(restaurant);
                    }
                    catch (Exception)
                    {
                        failures += 1;
                    }
                    if (!result.Success)
                    {
                        failures += 1;
                    }
                    else
                    {
                        successes += 1;
                    }
                }
                if (failures > 0)
                {
                    resultMessage.Success = false;
                    resultMessage.Message = "Updated {0}, Failed to Update {1}  row(s)".FormatWith(successes, failures);
                    return(Json(resultMessage));
                }
                resultMessage.Success = true;
                resultMessage.Message = "Updated {0} row(s).".FormatWith(successes);
            }
            catch (Exception ex)
            {
                resultMessage.Success = false;
                resultMessage.Message = "Error updating row(s). " + ex.Message;
            }
            return(Json(resultMessage));
        }
Example #13
0
        public async Task <ActionResult> Create(ResultMessages <schemeViewModel> schemes)
        {
            ResultMessages <schemeViewModel> result = null;

            try
            {
                var routeslist = _routesService.GetQueryable(x => x.Id != null);
                ViewBag.routes = new SelectList(routeslist.ToList(), "Id", "Name");
                //ViewData["RoutesId"] = ViewBag.routes;

                var feeslist = _feesService.GetQueryable(x => x.Id != null);
                ViewBag.fees = new SelectList(feeslist.ToList(), "Id", "Name");

                var channelslist = _channelsService.GetQueryable(x => x.Id != null);
                ViewBag.channels = new SelectList(channelslist.ToList(), "Id", "Name");

                var translist = _transTypeService.GetQueryable(x => x.Id != null);
                ViewBag.trans = new SelectList(translist.ToList(), "Id", "Name");


                if (ModelState.IsValid)
                {
                    schemes.Data.Id = Guid.NewGuid();

                    //db.Schemes.Add(schemes);
                    var channels = await _channelsService.GetByIdAsync(schemes.Data.ChannelId);

                    var fees = await _feesService.GetByIdAsync(schemes.Data.FeesId);

                    var routes = await _routesService.GetByIdAsync(schemes.Data.RoutesId);

                    var transtype = await _transTypeService.GetByIdAsync(schemes.Data.TransTypeId);

                    await _schemeService.SaveAsync(schemes.Data.ConvertToEntityModel(channels, fees, routes, transtype));

                    result      = new ResultMessages <schemeViewModel>();
                    result.Data = schemes.Data;
                    // return RedirectToAction("Index");
                }
            }
            catch (Exception ex)
            {
                result = new ResultMessages <schemeViewModel>(false, ex.Message);
            }

            return(View(result));
        }
Example #14
0
        public async Task <JsonResult> AddNewRestaurant(string NewRow)
        {
            var result = ResultMessages.JsonResultMessage();

            result.Message = "Error Adding New Row.";
            result.Success = false;
            try
            {
                Restaurant newRestaurant = JsonConvert.DeserializeObject <Restaurant>(NewRow);
                result = await _restaurantManager.AddNewRestaurantAsync(newRestaurant);
            }
            catch (Exception e)
            {
                result.Message = "Error Adding New Row.";
                result.Success = false;
                return(Json(result));
            }
            return(Json(result));
        }
Example #15
0
        public ActionResult Delete(int id)
        {
            List <string> errors = _profileAppService.Delete(id);

            if (errors?.Count > 0)
            {
                if (errors.Contains(CodLogErrorEnum.CODELOGERROR.ToString()))
                {
                    this.Flash("Error", ResultMessages.AplicationException());
                }
                else
                {
                    var errorListGroupped = errors.Aggregate((i, j) => i + "<br/>" + j);
                    this.Flash("Error", errorListGroupped);
                }
            }
            else
            {
                this.Flash("Success", ResultMessages.Success());
            }

            return(RedirectToAction("Index"));
        }
Example #16
0
        public JsonResult editDropdownUrl(string selectlist)
        {
            var resultMessage = ResultMessages.JsonResultMessage();

            try
            {
                var results = from CuisineType d in Enum.GetValues(typeof(CuisineType))
                              select new { ID = (int)d, Name = d.ToString() };
                IEnumerable <SelectListItem> cuisineTypes = results.Select(m => new SelectListItem
                {
                    Value = m.ID.ToString(),
                    Text  = m.Name
                }).Distinct().ToList();

                return(Json(cuisineTypes));
            }
            catch (Exception ex)
            {
                resultMessage.Success = false;
                resultMessage.Message = "Error retrieving select list information. " + ex.Message;
            }

            return(Json(resultMessage));
        }
Example #17
0
        public ActionResult SubmitLootSplit(LootViewModel model, string lootSplitName)
        {
            var resultMessage = ResultMessages.JsonResultMessage();

            resultMessage.Message = "Successfully Submitted Loot Split.";
            resultMessage.Success = true;
            //save
            if (model.SelectedLootSplitId == 0)
            {
                try
                {
                    var       failures  = 0;
                    var       successes = 0;
                    var       result    = resultMessage;
                    LootSplit lootSplit = new LootSplit();
                    lootSplit.Name = model.Name;
                    List <SplitItem> splitItems = new List <SplitItem>();

                    foreach (LootItem lootitem in model.LootItems)
                    {
                        if (lootitem.Quantity > 0)
                        {
                            SplitItem splitItem = new SplitItem();
                            splitItem.LootSplitId      = lootSplit.LootSplitId;
                            splitItem.LootItemId       = lootitem.LootItemId;
                            splitItem.LootItemQuantity = lootitem.Quantity;
                            splitItems.Add(splitItem);
                        }
                    }

                    lootSplit.SplitItems = splitItems;
                    lootSplit            = _lootManager.InsertLootSplit(lootSplit);

                    //_lootManager.InsertSplitItems(splitItems, lootSplit.Id);
                    if (failures > 0)
                    {
                        resultMessage.Success = false;
                        resultMessage.Message = "Insert Failed ";
                        return(Json(resultMessage));
                    }
                    resultMessage.Success = true;
                    resultMessage.Message = "Inserted {0} Loot Splits(s).".FormatWith(successes);
                }
                catch (Exception ex)
                {
                    resultMessage.Success = false;
                    resultMessage.Message = "Error Inserting Loot Split. " + ex.Message;
                }
            }
            //load
            else
            {
                model.LootSplitSelectList = new SelectList(_lootManager.GetLootSplitDropdownValues(),
                                                           "LootSplitId", "Name");
                model.LootItems = _lootManager.GetAllLootItems().ToList();
                IEnumerable <SplitItem> splitItems = _lootManager.GetSplitItems(model.SelectedLootSplitId);
                foreach (LootItem lootItem in model.LootItems)
                {
                    foreach (SplitItem splitItem in splitItems)
                    {
                        if (splitItem.LootItemId == lootItem.LootItemId)
                        {
                            lootItem.Quantity = splitItem.LootItemQuantity;
                        }
                    }
                }
                foreach (SelectListItem item in model.LootSplitSelectList)
                {
                    if (item.Value == model.SelectedLootSplitId.ToString())
                    {
                        item.Selected = true;
                    }
                }
            }
            return(View("Index", model));
        }
Example #18
0
 private void OnLogicMessagedRaised(object sender, BaseMessageEventArgs e)
 {
     ResultMessages.Document.Blocks.Add(new Paragraph(new Run(e.Message)));
     ResultMessages.ScrollToEnd();
 }