public bool isValid(params Role[] roles) { Boolean[] isRolePresentFlag = new Boolean[restrictedRoleIds.Length]; for (Int32 i = 0; i < restrictedRoleIds.Length; i++) { isRolePresentFlag[i] = roles.Count((v) => { return v.Id == restrictedRoleIds[i]; }) > 0; } return isRolePresentFlag.Count((b) => { return b == true; }) <= 1; }
public IActionResult AddFood(List<Guid> ids, List<Int32> quantity, DateTime Day, Boolean[] tess) { List<Guid> properIds = new List<Guid>(); List<Int32> properQuantities = new List<int>(); for (int i = 0; i < tess.Count(); i++) { if (tess[i]) { properIds.Add(ids[i]); properQuantities.Add(quantity[i]); } } List<Int32> properMealTypes = new List<int>(); var enumMealType = TempData[mealTypeId] as Int32?; for (int i = 0; i < properIds.Count(); i++) properMealTypes.Add((Int32)enumMealType); var guids = TempData[productGuidId] as IEnumerable<Guid>; if (guids != null && guids.Count() != 0) { var quants = TempData[productQuantityId] as IEnumerable<Int32>; var mealType = TempData[productMealTypeId] as IEnumerable<Int32>; properIds.AddRange(guids); properQuantities.AddRange(quants); properMealTypes.AddRange(mealType); } TempData[additionalMealsId] = true; TempData[productGuidId] = properIds; TempData[productQuantityId] = properQuantities; TempData[productMealTypeId] = properMealTypes; TempData[mealTypeId] = enumMealType; String id = String.Empty; String month = String.Empty; if (Day.Month < 10) month = String.Format("0{0}", Day.Month); else month = Day.Month.ToString(); id = String.Format("{0}-{1}-{2}", Day.Day.ToString(), month, Day.Year.ToString()); return RedirectToAction("Day", "Diet", new { id = id} ); }