Esempio n. 1
0
 public JsonResult CreateCompany(CompanyCreateModel createModel)
 {
     if (service.ExistsCompanyWithEniroId(createModel.EniroId))
     {
         createModel.CreateMsg = "Företaget med Eniroid '" + createModel.EniroId + "' finns redan i systemet!";
         return Json(createModel, JsonRequestBehavior.AllowGet);
     }
     createModel.Id = service.CreateCompany(createModel);
     return Json(createModel, JsonRequestBehavior.AllowGet);
 }
Esempio n. 2
0
        public static long CreateCompany(CompanyCreateModel createModel)
        {
            var db = new DataContext();
            var c = new Company(createModel.IsRestaurant)
                        {
                            Name = createModel.CompanyName,
                            Organisationnr = createModel.Organisationnr,
                            Information = createModel.Information,
                            Notes = createModel.Notes,
                            Latitude = createModel.Latitude,
                            Longitude = createModel.Longitude,
                            EniroId = createModel.EniroId,
                            Email = createModel.Email,
                            Url = createModel.Url,
                            //PhoneNumbers = model.PhoneNumbers.Select(p => new PhoneNumber {
                            //    Number = p.Number,
                            // Type = (PhoneNumberType) p.Type
                            // }).ToList(),
                            Adress = new Adress
                                         {
                                             PostCode = createModel.PostCode,
                                             Street = createModel.Street,
                                             PostArea = createModel.PostArea
                                         }
                        };

            try
            {
                db.Companies.Add(c);
                //c.Adress.City = db.Cities.Find(c.Adress.City.Id);

                if (createModel.IsRestaurant)
                {
                    var r = new Restaurant();
                    var area = db.LunchAreas.Find(createModel.LunchAreaId);
                    r.SetDataFromCompany(c, area);
                    r.Areas.Add(area);
                    db.Restaurants.Add(r);
                }
                db.SaveChanges();
                return c.Id;
            }
            catch (Exception ex)
            {
                throw new Exception();
            }
        }
Esempio n. 3
0
 //public IEnumerable<RestaurantViewModel> GetRestaurants()
 //{
 //    return RestaurantManager.GetRestaurants();
 //}
 //public IEnumerable<DishViewModel> GetDishes()
 //{
 //    return RestaurantManager.GetDishes();
 //}
 public long CreateCompany(CompanyCreateModel createModel)
 {
     return CompanyManager.CreateCompany(createModel);
 }