[HttpPost("registerVeterinarian")] //http://localhost:5000/Veterinarian/registerVeterinarian
        public async Task <ActionResult <VeterinarianModel> > RegisterVeterinarian(UserModel user)
        {
            try
            {
                bool existUser = dBContext.Users.Any(e => e.Email == user.Email);
                if (!existUser && user.UserType == 0)
                {
                    dBContext.Users.Add(user);
                    await dBContext.SaveChangesAsync();

                    VeterinarianModel vet = new VeterinarianModel();
                    vet.IdUser = user.IdUser;
                    dBContext.Veterinarians.Add(vet);
                    await dBContext.SaveChangesAsync();

                    return(Ok(vet));
                }
                else
                {
                    return(StatusCode(410));
                }
            }
            catch (Exception e)
            {
                return(StatusCode(410));
            }
        }
示例#2
0
        [HttpPost("registerClient")] //http://localhost:5000/client/registerClient
        public async Task <ActionResult <ClientModel> > RegisterClient(UserModel user)
        {
            try
            {
                bool existUser = dBContext.Users.Any(e => e.Email == user.Email);
                if (!existUser && user.UserType == 1)
                {
                    dBContext.Users.Add(user);
                    await dBContext.SaveChangesAsync();

                    ClientModel client = new ClientModel();
                    client.IdUser = user.IdUser;
                    dBContext.Clients.Add(client);
                    await dBContext.SaveChangesAsync();

                    return(Ok(client));
                }
                else
                {
                    return(StatusCode(410));
                }
            }
            catch (Exception e)
            {
                return(StatusCode(410));
            }
        }
示例#3
0
        [HttpPut("update/{id}")] //http:localhost:5000/user/update
        public async Task <IActionResult> UpdateUser(long id, UserModel user)
        {
            try
            {
                if (id != user.IdUser)
                {
                    return(BadRequest());
                }
                else
                {
                    dBContext.Entry(user).State = EntityState.Modified; //
                    await dBContext.SaveChangesAsync();

                    return(NoContent());
                }
            }
            catch (Exception e)
            {
                bool existUser = dBContext.Users.Any(e => e.IdUser == id);
                if (!existUser)
                {
                    return(NotFound());
                }
                else
                {
                    return(StatusCode(410));
                }
            }
        }
示例#4
0
        [HttpPost("create")]//http://localhost:5000/Category/create
        public async Task <ActionResult <CategoryModel> > CreateCategory(CategoryModel category)
        {
            try {
                dBContext.Categories.Add(category);
                await dBContext.SaveChangesAsync();

                return(Ok(category));
            }
            catch (Exception e) {
                return(StatusCode(410));
            }
        }
示例#5
0
        public async Task <ActionResult <AppointmentModel> > CreateAppointment(AppointmentModel appointment)
        {
            try {
                dBContext.Appointments.Add(appointment);
                await dBContext.SaveChangesAsync();

                return(Ok(appointment));
            }
            catch (Exception e) {
                return(StatusCode(410));
            }
        }
        [HttpPost("create")]//http://localhost:5000/Product/create
        public async Task <ActionResult <ProductModel> > CreateProduct(ProductModel product)
        {
            try {
                dBContext.Products.Add(product);
                await dBContext.SaveChangesAsync();

                return(Ok(product));
            }
            catch (Exception e) {
                return(StatusCode(410));
            }
        }
示例#7
0
        public async Task <ActionResult <WishListModel> > CreateWishList(WishListModel wishList)
        {
            try {
                dBContext.WishLists.Add(wishList);
                await dBContext.SaveChangesAsync();

                return(Ok(wishList));
            }
            catch (Exception e) {
                return(StatusCode(410));
            }
        }
示例#8
0
        [HttpPost("create")]//http://localhost:5000/WishList_Productss/create
        public async Task <ActionResult <WishList_ProductsModel> > PostWishList_Products(WishList_ProductsModel wishList_products)
        {
            try {
                dBContext.WishLists_Products.Add(wishList_products);
                await dBContext.SaveChangesAsync();

                return(Ok(wishList_products));
            }
            catch (Exception e) {
                return(StatusCode(410));
            }
        }
        public async Task <ActionResult <SpecialtyModel> > CreateSpecialty(SpecialtyModel specialty)
        {
            try {
                dBContext.Specialties.Add(specialty);
                await dBContext.SaveChangesAsync();

                return(Ok(specialty));
            }
            catch (Exception e) {
                return(StatusCode(410));
            }
        }
示例#10
0
        [HttpPost("create")] //http:localhost:5000/statesOrder/create
        public async Task <ActionResult <StateOrderModel> > CreateStateOrder(StateOrderModel stateOrder)
        {
            try
            {
                dBContext.StatesOrder.Add(stateOrder);
                await dBContext.SaveChangesAsync();

                return(Ok(stateOrder));
            }
            catch (Exception e)
            {
                return(StatusCode(410));
            }
        }
        [HttpPost("create")] //http:localhost:5000/order/create
        public async Task <ActionResult <OrderRecordModel> > CreateOrderRecord(OrderRecordModel orderrecord)
        {
            try
            {
                dBContext.OrdersRecords.Add(orderrecord);
                await dBContext.SaveChangesAsync();

                return(Ok(orderrecord));
            }
            catch (Exception e)
            {
                return(StatusCode(410));
            }
        }
示例#12
0
        [HttpPost("create")] //http:localhost:5000/order_products/create
        public async Task <ActionResult <Order_ProductsModel> > CreateOrder_Products(Order_ProductsModel order_products)
        {
            try
            {
                dBContext.Orders_Products.Add(order_products);
                await dBContext.SaveChangesAsync();

                return(Ok(order_products));
            }
            catch (Exception e)
            {
                return(StatusCode(410));
            }
        }
示例#13
0
        [HttpPost("create")] //http:localhost:5000/order/create
        public async Task <ActionResult <OrderModel> > CreateOrder(Object order)
        {
            try
            {
                //Console.WriteLine(order.ToString());
                var jsonString = order.ToString();
                var dic        = JsonConvert.DeserializeObject <Dictionary <string, object> >(jsonString);
                Console.WriteLine(dic["TotalValue"]);
                OrderModel newOrder = Parsing(dic);
                dBContext.Orders.Add(newOrder);
                await dBContext.SaveChangesAsync();

                var idNewOrder = newOrder.IdOrder;
                var listDic    = JsonConvert.DeserializeObject <List <Dictionary <string, string> > >(dic["Products"].ToString());
                foreach (Dictionary <string, string> d in listDic)
                {
                    Order_ProductsModel newOrder_Product = new Order_ProductsModel();
                    newOrder_Product.IdOrder        = idNewOrder;
                    newOrder_Product.IdProduct      = long.Parse(d["IdProduct"]);
                    newOrder_Product.QuantityBought = int.Parse(d["QuantityBought"]);
                    ProductModel pm = await pC.GetProductModel(newOrder_Product.IdProduct);

                    pm.QuantityAvailable -= newOrder_Product.QuantityBought;
                    await pC.UpdateProduct(pm, newOrder_Product.IdProduct);

                    dBContext.Orders_Products.Add(newOrder_Product);
                }
                await dBContext.SaveChangesAsync();

                return(Ok(order));
            }
            catch (Exception e)
            {
                return(StatusCode(410));
            }
        }