Esempio n. 1
0
        public JsonResult Post(AdvisorViewModel model)
        {
            Models.Type type = _typesManager.GetTypeByName(model.Type);

            var result = _recipeManager.GetRandRecipe(type);

            if (result != null)
            {
                ReturnRecipeModel recipe = new ReturnRecipeModel
                {
                    Name        = result.Name,
                    Description = result.Description,
                    Ingredients = result.Ingredients,
                    Process     = result.Process,
                    Author      = result.Author
                };
                return(new JsonResult {
                    Data = recipe, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            return(new JsonResult {
                Data = "Error", JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Esempio n. 2
0
 public void Create(Models.Type type)
 {
     using (var conn = NewConnection)
     {
         conn.Execute(Scripts.CreateType, type);
     }
 }
Esempio n. 3
0
        public JsonResult Put(RecipeViewModel model)
        {
            Models.Type type = _typesManager.GetTypeByName(model.Type);

            var recipe = new Recipe
            {
                Name        = model.Name,
                Description = model.Description,
                Ingredients = model.Ingredients,
                Process     = model.Process,
                Author      = model.Author,
                TypeId      = type.Id
            };

            var result = _recipeManager.AddRecipe(recipe);

            if (result.Succeeded)
            {
                var message = "Success";
                return(new JsonResult {
                    Data = message, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            return(new JsonResult {
                Data = result.Errors.ToString(), JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Esempio n. 4
0
        public JsonResult NewType(Models.Type type)
        {
            context.TYPE.Add(type);
            context.SaveChanges();

            return(Json("başarılı"));
        }
Esempio n. 5
0
        public DetailReturnDisk Search(int diskID)
        {
            DetailReturnDisk detail;

            using (ApplicationDBContext db = new ApplicationDBContext())
            {
                CustomerBS c = new CustomerBS();
                Disk       d = db.Disks.SingleOrDefault(x => x.DiskID == diskID && x.ChkOutStatus == (short)Checkout.DiskStatus.RENTED);
                if (d != null)
                {
                    var query = from rd1 in db.Rentail_Detail
                                join r1 in db.Rentals on rd1.RentalID equals r1.RentalID
                                where rd1.DiskID == diskID && r1.Status == (int)RentalInformation.RentalStatus.RENTED
                                select new
                    {
                        rd1,
                        r1
                    };



                    if (query.FirstOrDefault() != null)

                    {
                        Rentail_Detail rd    = (Rentail_Detail)query.FirstOrDefault().rd1;
                        Rental         r     = (Rental)query.FirstOrDefault().r1;
                        Title          title = db.Titles.Single(x => x.TitleID == d.TitleID);
                        Models.Type    t     = db.Types.Single(x => x.TypeID == title.TypeID);
                        detail = new DetailReturnDisk(r.CusID, d.TitleID, d.DiskID, r.StartRentDate, (DateTime)rd.DueDate, DateTime.Now, c.getName(r.CusID), getTitleName(d.TitleID), t.RentCharge);
                        return(detail);
                    }
                }
                return(null);
            }
        }
Esempio n. 6
0
        private bool DownloadFile(Computer cpu, string fileName, Models.Type type)
        {
            string localFile  = String.Empty;
            string remoteFile = String.Empty;

            switch (type)
            {
            case Models.Type.CALL:
            {
                localFile  = String.Format(@"{0}\{1}", localCallsFolder, fileName);
                remoteFile = String.Format("{0}/calls/{1}", path, fileName);
            }
            break;

            case Models.Type.SMS:
            {
                localFile  = String.Format(@"{0}\{1}", localSmsFolder, fileName);
                remoteFile = String.Format("{0}/sms/{1}", path, fileName);
            }
            break;
            }



            return(Service.DownloadFile(cpu, localFile, remoteFile));
        }
Esempio n. 7
0
        public static PokemonSpeciesDto ToDto(this Pokemon_Species pokemonSpecies)
        {
            var firstType = pokemonSpecies.FirstType ?? new Models.Type()
            {
                Id = pokemonSpecies.First_Type_Id
            };

            Models.Type secondType = null;
            if (pokemonSpecies.SecondType != null || pokemonSpecies.Second_Type_Id != null)
            {
                secondType = pokemonSpecies.SecondType ?? new Models.Type()
                {
                    Id = pokemonSpecies.Second_Type_Id.Value
                }
            }
            ;

            return(new PokemonSpeciesDto()
            {
                Id = pokemonSpecies.Id,
                NationalNumb = pokemonSpecies.National_Numb,
                Name = pokemonSpecies.Name,
                BaseHp = pokemonSpecies.Base_Hp,
                BaseAttack = pokemonSpecies.Base_Attack,
                BaseDefense = pokemonSpecies.Base_Defense,
                BaseSpAttack = pokemonSpecies.Base_Sp_Attack,
                BaseSpDefense = pokemonSpecies.Base_Sp_Defense,
                BaseSpeed = pokemonSpecies.Base_Speed,
                FirstType = firstType.ToDto(),
                SecondType = secondType != null?secondType.ToDto() : null
            });
        }
    }
Esempio n. 8
0
        List <Beer> ConvertToBeer(List <CsvModel> CsvModelList)
        {
            List <Beer> _beerList = new List <Beer>();

            for (int i = 0; i < CsvModelList.Count; i++)
            {
                CsvModel csvModel = CsvModelList[i];
                if (csvModel.Quantity > 0)
                {
                    Brewery     brewery = new Brewery();
                    Models.Type type    = new Models.Type();
                    brewery.BreweryName = csvModel.Provider;
                    type.TypeName       = csvModel.Group;
                    type.FoodParing     = csvModel.Provider;//docelowo foodparing

                    Beer beer = new Beer(csvModel.Name, brewery, csvModel.NetPrice, csvModel.PurchasePrice, type, csvModel.UnitWeight, csvModel.Description);
                    beer.BrewerName = brewery.BreweryName;
                    beer.TypeName   = type.TypeName;

                    UpdateDataBases(ref brewery, ref type);
                    beer.BreweryID  = brewery.BreweryID;
                    beer.TypeID     = type.TypeID;
                    beer.PriceListA = CountGrossPrice(csvModel.NetPrice);
                    beer.Quantity   = csvModel.Quantity;
                    beer.EanCode    = csvModel.Code;
                    //beer.PhotoPath = csvModel.FilePickturePath;
                    beer.PhotoPath = ConvertPath(csvModel.FilePickturePath);
                    beer.Plato     = csvModel.PackageWeight;

                    _beerList.Add(beer);
                    KatalogPiw.App.Database.SaveBeer(beer);
                }
            }
            return(_beerList);
        }
Esempio n. 9
0
        public MovieResponse MovieDetails(int id)
        {
            Dictionary <string, string[]> errors = new Dictionary <string, string[]>();

            var movie = _context.Movies.FirstOrDefault(m => m.MovieId == id);

            if (movie == null)
            {
                errors.Add("Movie", new[] { "Nie istanieje taki film" });
                return(new MovieResponse(errors));
            }
            Models.Type type = _context.Types.FirstOrDefault(t => t.TypeId == movie.TypeId);

            MovieReturnDto movieReturn = _mapper.Map <Movie, MovieReturnDto>(movie);

            movieReturn.Actors = new List <ActorInFilm>();
            movieReturn.Type   = type.Name;

            foreach (var e in _context.MoviesToActor.Where(m => m.MovieId == id))
            {
                Actor       tmp   = _context.Actors.FirstOrDefault(a => a.ActorId == e.Actor);
                ActorInFilm actor = new ActorInFilm
                {
                    NameSurname       = tmp.Name + " " + tmp.Surname,
                    NameSurnameInFilm = e.ActorNameInMovie
                };
                movieReturn.Actors.Add(actor);
            }
            return(new MovieResponse(movieReturn));
        }
        public ActionResult Create(RegisterRestaurantModel model, HttpPostedFileBase image)
        {
            if (ModelState.IsValid)
            {
                Restaurant restaurant = model.restaurant;
                if (model.restTypesId != null)
                {
                    foreach (var typeId in model.restTypesId)
                    {
                        Models.Type restType = db.Type.Find(typeId);
                        restType.Restaurant.Add(restaurant);
                        restaurant.Type.Add(restType);
                    }
                }
                if (image != null)
                {
                    byte[] dbImage = FileUpload(image);
                    restaurant.Logo = dbImage;
                }
                var identity = (System.Web.HttpContext.Current.User as MyIdentity.MyPrincipal).Identity as MyIdentity;
                restaurant.IdAdmin = identity.User.IdCard;
                db.Restaurant.Add(restaurant);

                db.SaveChanges();
                TempData["Success"] = restaurant.Name + " created successfully.";
                return(RedirectToAction("Index"));
            }
            ViewBag.Type = new SelectList(db.Type, "IdType", "Name");
            return(View(model));
        }
Esempio n. 11
0
 public Dish GetRandomDish(List <Dish> dishesNotToRepeat, Models.Type mealType, int minTuppers)
 {
     return(_repository.GetDishes().Where(x => !dishesNotToRepeat.Select(y => y.Id).Contains(x.Id) &&
                                          x.Type == mealType &&
                                          x.Tuppers >= minTuppers)
            .OrderBy(r => Guid.NewGuid()).FirstOrDefault());
 }
Esempio n. 12
0
        public IHttpActionResult PutType(int id, Models.Type type)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != type.Id)
            {
                return(BadRequest());
            }

            db.Entry(type).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 13
0
        public async Task <ActionResult <Models.Type> > PostType(Models.Type @type)
        {
            _context.Types.Add(@type);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetType", new { id = @type.Id }, @type));
        }
Esempio n. 14
0
        internal static bool DeleteFile(Computer cpu, string fileName, Models.Type fileType)
        {
            if (Initialize(cpu))
            {
                string command = String.Empty;
                switch (fileType)
                {
                case Models.Type.CALL:
                    command = String.Format("cd calls && rm {0} &", fileName);
                    break;

                case Models.Type.SMS:
                    command = String.Format("cd sms && rm {0} &", fileName);
                    break;;
                }
                shellStream.WriteLine(command);
#if (DEBUG)
                string feedback = shellStream.Expect("root", new TimeSpan(0, 0, 10));
#endif
                sshClient.Disconnect();

                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 15
0
        public ActionResult Index()
        {
            Design design = new Design();

            design.Id_user = Convert.ToInt32(Session["user"]);
            design.Affiche(1);
            Session["design"]    = design.Designs;
            Session["datatable"] = design.Datatable;
            Session["btn"]       = design.Btn;
            if (Session["name"] != null)
            {
                if (Convert.ToInt32(Session["typeprofil"]) == 1)
                {
                    Commande commande = new Commande();
                    ViewBag.nbcmd = commande.countcmd();
                    Client client = new Client();
                    ViewBag.nbclt = client.countclt();
                    Product product = new Product();
                    ViewBag.nbpdt = product.countpdt();
                    Models.Type type = new Models.Type();
                    ViewBag.nbtype = type.counttype();
                    return(View());
                }
                else
                {
                    return(RedirectToAction("Index", "Commande"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "Login"));
            }
        }
        public List <Beer> FiltringBeers(string searchBarText, object breweryListObject, object typeListObject, double value)
        {
            List <Beer> beers = new List <Beer>();

            if (breweryListObject == null && typeListObject == null)
            {
                return(beers = Beers.Where(i => ((i.BrewerName.ToLower().Contains(searchBarText.ToLower()) ||
                                                  (i.TypeName.ToLower().Contains(searchBarText.ToLower())))) && (i.Quantity > (int)value)).ToList());
            }
            else if (breweryListObject == null)
            {
                Models.Type type = (Models.Type)typeListObject;

                return(beers = Beers.Where(i => ((i.BrewerName.ToLower().Contains(searchBarText.ToLower()) ||
                                                  (i.TypeName.ToLower().Contains(searchBarText.ToLower())))) && (i.Quantity > (int)value) && (i.TypeID == type.TypeID)).ToList());
            }
            else if (typeListObject == null)
            {
                Brewery brewery = (Brewery)breweryListObject;
                return(beers = Beers.Where(i => ((i.BrewerName.ToLower().Contains(searchBarText.ToLower()) ||
                                                  (i.TypeName.ToLower().Contains(searchBarText.ToLower())))) && (i.Quantity > (int)value) && (i.BreweryID == brewery.BreweryID)).ToList());
            }
            else
            {
                Brewery     brewery = (Brewery)breweryListObject;
                Models.Type type    = (Models.Type)typeListObject;
                return(beers = Beers.Where(i => ((i.BrewerName.ToLower().Contains(searchBarText.ToLower()) ||
                                                  (i.TypeName.ToLower().Contains(searchBarText.ToLower())))) && (i.Quantity > (int)value) && (i.BreweryID == brewery.BreweryID) && (i.TypeID == type.TypeID)).ToList());
            }
        }
Esempio n. 17
0
        public void updateContentElements(int listCeId, String[] description, String[] url, int[] order, String[] type)
        {
            List <ContentElement> contentElements = db.ContentElements.Where(ce => ce.ContentGroupId == listCeId).ToList();

            foreach (var ce in contentElements)
            {
                db.ContentElements.Remove(ce);
            }


            for (int i = 0; i < description.Length; i++)
            {
                ContentElement ce = new ContentElement();
                Models.Type    t  = new Models.Type();
                //if(db.Types.Contains(type[i]))
                t.Name = type[i];

                //Course course = db.Courses.Find(id);

                ce.Description    = description[i];
                ce.URL            = url[i];
                ce.Order          = order[i];
                ce.Type           = t;
                ce.ContentGroup   = db.ContentGroups.Find(listCeId);
                ce.ContentGroupId = listCeId;

                db.Types.Add(t);
                db.ContentElements.Add(ce);
            }
            db.SaveChanges();
        }
Esempio n. 18
0
        public HttpResponseMessage PostType(Models.Type type)
        {
            db.Database.Log = (message) => Debug.WriteLine(message);

            var token = Request.Headers;

            if (!token.Contains(Authentication.TOKEN_KEYWORD))
            {
                return(Request.CreateResponse(HttpStatusCode.Forbidden, Responses.CreateForbiddenResponseMessage()));
            }
            string accessToken = Request.Headers.GetValues(Authentication.TOKEN_KEYWORD).FirstOrDefault();

            if (Authentication.IsAuthenticated(accessToken))
            {
                return(Request.CreateResponse(HttpStatusCode.Forbidden, Responses.CreateForbiddenResponseMessage()));
            }

            var newType = new Models.Type()
            {
                TypeName  = type.TypeName,
                TypePrice = type.TypePrice,
                CreatedAt = DateTime.Now,
                UpdDate   = DateTime.Now
            };

            db.Types.Add(newType);
            db.SaveChanges();

            return(Request.CreateResponse(HttpStatusCode.Created));
        }
        public IActionResult Details()
        {
            if (!this.User.IsAuthenticated)
            {
                return(RedirectToAction("/user/login"));
            }

            if (userIsAdmin())
            {
                this.Model["isAdmin"] = "block";
            }
            else
            {
                this.Model["isAdmin"] = "none";
            }

            int id = int.Parse(this.Request.UrlParameters["id"]);

            Product product = this.Context.Products.FirstOrDefault(t => t.Id == id);


            Models.Type type = this.Context.Types.FirstOrDefault(t => t.Id == product.TypeId);

            this.Model["name"]        = product.Name.ToString();
            this.Model["id"]          = product.Id.ToString();
            this.Model["type"]        = type.Name;
            this.Model["price"]       = product.Price.ToString();
            this.Model["description"] = product.Description.ToString();
            return(View());
        }
Esempio n. 20
0
        public async Task <IActionResult> PutType([FromRoute] int id, [FromBody] Models.Type @type)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != @type.Id)
            {
                return(BadRequest());
            }

            _context.Entry(@type).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 21
0
 public ActionResult DeleteConfirmed(int id)
 {
     Models.Type type = db.Type.Find(id);
     db.Type.Remove(type);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Esempio n. 22
0
        public ActionResult Edit([Bind(Include = "Id,File_Id,Name,Description,Notes,CreateDate,UpdateDate,del_file")] Models.Type type)
        {
            if (ModelState.IsValid)
            {
                db.Entry(type).State = EntityState.Modified;
                type.UpdateDate      = new SqlDateTime(DateTime.Now).Value;

                var checkbox = ValueProvider.GetValue("del_file");
                if (checkbox != null)
                {
                    var fid  = Int32.Parse(checkbox.AttemptedValue.Replace('/', '\0'));
                    var file = db.File.Find(fid);

                    if (System.IO.File.Exists(Server.MapPath(file.File_Path)))
                    {
                        System.IO.File.Delete(Server.MapPath(file.File_Path));
                        db.Type.Find(type.Id).File = null;
                        type.File_Id = null;
                        db.File.Remove(file);
                    }
                }

                db.SaveChanges();
                return(RedirectToAction("Details", new { id = type.Id }));
            }
            return(View(type));
        }
Esempio n. 23
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Description")] Models.Type @type)
        {
            if (id != @type.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(@type);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TypeExists(@type.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(@type));
        }
Esempio n. 24
0
        // PUT: api/Type/5
        public HttpResponseMessage Put([FromBody] Models.Type value)
        {
            TypePersistence     oTP       = new TypePersistence();
            HttpResponseMessage oResponse = Request.CreateResponse(oTP.putType(value) ? HttpStatusCode.NoContent : HttpStatusCode.NotFound);

            return(oResponse);
        }
Esempio n. 25
0
 public ActionResult DeleteConfirmed(int id)
 {
     Models.Type type = db.Types.Find(id);
     type.Enable          = false;
     db.Entry(type).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Esempio n. 26
0
 public void Delete(int id)
 {
     Models.Type type = _typeRepository.Get(id);
     if (type != null)
     {
         _typeRepository.Remove(type);
     }
 }
Esempio n. 27
0
        public bool Delete(Models.Type type)
        {
            _applicationDbContext.Entry(type).State = EntityState.Deleted;

            _applicationDbContext.Types.Remove(type);

            return(_applicationDbContext.SaveChanges() > 0);
        }
Esempio n. 28
0
 public static TypeDto ToDto(this Models.Type type)
 {
     return(new TypeDto()
     {
         Id = type.Id,
         Name = type.Name?.ToLower()
     });
 }
Esempio n. 29
0
        // GET: api/Type/5
        public Models.Type Get(long id)
        {
            TypePersistence oTP = new TypePersistence();

            Models.Type oType = oTP.getType(id);

            return(oType);
        }
Esempio n. 30
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Models.Type type = await db.Types.FindAsync(id);

            db.Types.Remove(type);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }