コード例 #1
0
ファイル: CareRepository.cs プロジェクト: antonreznik/Shop
        //-----------------------------------------------------------
        //Выбираем продукт по идшнику
        public Care GetProductById(int ProductId)
        {
            Care obj = context.Cares.FirstOrDefault(product => product.ProductId == ProductId);

            obj.Colors = new List <Color>();
            return(obj);
        }
コード例 #2
0
        //------------------------------------------------------
        //Удаление товара
        public ActionResult DeleteProduct(int ProductId, int CategoryId)
        {
            if (CategoryId == 1)
            {
                Parfum obj = productrepo.GetProductById(ProductId);
                productrepo.DeleteProduct(obj);
                TempData["message"] = String.Format("Товар '{0}' удален из базы", obj.ProductName);
                return(RedirectToAction("ShowProductsInCategory", "Admin", new { obj.CategoryId }));
            }

            else if (CategoryId == 2)
            {
                Cosmetic obj = cosmeticrepo.GetProductById(ProductId);
                cosmeticrepo.DeleteProduct(obj);
                TempData["message"] = String.Format("Товар '{0}' удален из базы", obj.ProductName);
                return(RedirectToAction("ShowProductsInCategory", "Admin", new { obj.CategoryId }));
            }

            else if (CategoryId == 3)
            {
                Care obj = carerepo.GetProductById(ProductId);
                carerepo.DeleteProduct(obj);
                TempData["message"] = String.Format("Товар'{0}'удвлен из базы", obj.ProductName);
                return(RedirectToAction("ShowProductsInCategory", "Admin", new { obj.CategoryId }));
            }

            return(View());
        }
コード例 #3
0
ファイル: CareRepository.cs プロジェクト: antonreznik/Shop
        //----------------------------------------------------------


        //----------------------------------------------------------
        //Метод по добавлению нового товара и по сохранению изменений в существующих
        public void SaveProduct(Care obj)
        {
            if (obj.ProductId == 0)
            {
                context.Cares.Add(obj);
            }

            else
            {
                Care prod = context.Cares.Find(obj.ProductId);
                if (prod != null)
                {
                    prod.ProductName = obj.ProductName;
                    prod.CategoryId  = obj.CategoryId;
                    prod.NewPrice    = obj.NewPrice;
                    prod.Description = obj.Description;
                    prod.Type        = obj.Type;
                    if (obj.ImageMimeType != null && obj.ImageData != null)
                    {
                        prod.ImageData     = obj.ImageData;
                        prod.ImageMimeType = obj.ImageMimeType;
                    }
                }
            }
            context.SaveChanges();
        }
コード例 #4
0
        //------------------------------------------------------
        //Редактирование средств по уходу
        public ActionResult EditCare(int ProductId)
        {
            Care          care = carerepo.GetProductById(ProductId);
            CareViewModel obj  = Mapper.Map <CareViewModel>(care);

            return(View(obj));
        }
コード例 #5
0
        public IHttpActionResult PostCare(Care care)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Cares.Add(care);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (CareExists(care.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = care.Id }, care));
        }
コード例 #6
0
        public IHttpActionResult PutCare(int id, Care care)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #7
0
ファイル: CaresController.cs プロジェクト: ikumawoyi/market
        public async Task <IActionResult> Edit(int id, [Bind("CareId,CareCode,FirstName,OtherName,LastName,Name,Phone,DateCreated,DateUpdated,Passport")] Care care)
        {
            if (id != care.CareId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(care);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CareExists(care.CareId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(care));
        }
コード例 #8
0
        public async Task <ActionResult <Care> > PostCare(Care care)
        {
            _context.Care.Add(care);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCare", new { id = care.CareId }, care));
        }
コード例 #9
0
        public async Task <IActionResult> PutCare(int id, Care care)
        {
            if (id != care.CareId)
            {
                return(BadRequest());
            }

            _context.Entry(care).State = EntityState.Modified;

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

            return(NoContent());
        }
コード例 #10
0
ファイル: CaresController.cs プロジェクト: ikumawoyi/market
        public async Task <IActionResult> Create([Bind("CareId,CareCode,FirstName,OtherName,LastName,Name,Phone,DateCreated,DateUpdated,Passport")] Care care)
        {
            if (ModelState.IsValid)
            {
                _context.Add(care);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(care));
        }
コード例 #11
0
ファイル: CareRepository.cs プロジェクト: antonreznik/Shop
        //-----------------------------------------
        //Изменение доступности товара
        public void ChangeAvailability(int productId, bool isAvailable)
        {
            Care obj = GetProductById(productId);

            foreach (var item in obj.Colors)
            {
                context.Entry(item).State = EntityState.Modified;
            }
            obj.IsAvailable = isAvailable;
            context.SaveChanges();
        }
コード例 #12
0
ファイル: CareRepository.cs プロジェクト: antonreznik/Shop
        //-----------------------------------------
        //Добавление просмотра
        public void AddCountOfView(int productId)
        {
            Care obj = GetProductById(productId);

            foreach (var item in obj.Colors)
            {
                context.Entry(item).State = EntityState.Modified;
            }
            obj.CountOfView += 1;
            context.SaveChanges();
        }
コード例 #13
0
        public IHttpActionResult DeleteCare(int id)
        {
            Care care = db.Cares.Find(id);

            if (care == null)
            {
                return(NotFound());
            }

            db.Cares.Remove(care);
            db.SaveChanges();

            return(Ok(care));
        }
コード例 #14
0
        public void InsertCare(Care care)
        {
            Disease d = GetDiseases().Find(p => p.ID == care.Disease_Id);

            //乳房类:137,蹄类174
            if (d.DiseaseTypeID == 137 || d.DiseaseTypeID == 174)
            {
                medicalDAL.InsertCare(care, true);
            }
            else
            {
                medicalDAL.InsertCare(care, false);
            }
        }
コード例 #15
0
        public FileContentResult GetImage(int ProductId, int CategoryId)
        {
            if (CategoryId == 1)
            {
                Parfum obj = productrepo.GetProductById(ProductId);
                if (obj != null)
                {
                    return(File(obj.ImageData, obj.ImageMimeType));
                }

                else
                {
                    return(null);
                }
            }

            else if (CategoryId == 2)
            {
                Cosmetic obj = cosmeticrepo.GetProductById(ProductId);
                if (obj != null)
                {
                    return(File(obj.ImageData, obj.ImageMimeType));
                }

                else
                {
                    return(null);
                }
            }

            else if (CategoryId == 3)
            {
                Care obj = carerepo.GetProductById(ProductId);
                if (obj != null)
                {
                    return(File(obj.ImageData, obj.ImageMimeType));
                }

                else
                {
                    return(null);
                }
            }

            return(null);
        }
コード例 #16
0
        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            ObservableCollection <Care> caresearch = new ObservableCollection <Care>();

            caresearch.Clear();
            carelist1.ItemsSource = caresearch;

            //carelist.Items.Clear();
            Care   findcare = new Care();
            string txt      = txtbSearchCare.Text;

            findcare = careCollection.Where(x => x.careName == txtbSearchCare.Text).FirstOrDefault();
            if (findcare != null)
            {
                caresearch.Clear();
                caresearch.Add(findcare);
                carelist1.ItemsSource = caresearch;
            }
        }
コード例 #17
0
ファイル: MedicalDAL.cs プロジェクト: vijaydairyf/cow-1
        public void InsertCare(Care care, bool isBeastOrFoot)
        {
            string sql;

            if (isBeastOrFoot)
            {
                sql = string.Format(@"insert into Medical_Care(EarNum,Disease_Id,Prescription,DoctorID,Date,LeftFront,RightFront,RightBack,LeftBack)
                                         values ({0},{1},'{2}',{3},'{4}',{5},{6},{7},{8})",
                                    care.EarNum, care.Disease_Id, care.Prescription, care.DoctorID, DateTime.Now.ToShortDateString(),
                                    care.LeftFront, care.RightFront, care.LeftBack, care.RightBack);
            }
            else
            {
                sql = string.Format(@"insert into Medical_Care(EarNum,Disease_Id,Prescription,DoctorID,Date)
                                         values ({0},{1},'{2}',{3},'{4}')",
                                    care.EarNum, care.Disease_Id, care.Prescription, care.DoctorID, DateTime.Now.ToShortDateString());
            }

            dataProvider1mutong.ExecuteNonQuery(sql, CommandType.Text);
        }
コード例 #18
0
        public ActionResult AddCare(CareViewModel obj, HttpPostedFileBase Image)
        {
            if (ModelState.IsValid)
            {
                if (Image != null)
                {
                    obj.ImageMimeType = Image.ContentType;
                    obj.ImageData     = new byte[Image.ContentLength];
                    Image.InputStream.Read(obj.ImageData, 0, Image.ContentLength);
                }
                Care prod = Mapper.Map <Care>(obj);
                carerepo.SaveProduct(prod);
                TempData["message"] = String.Format("Товар '{0}' добавлен", obj.ProductName);
                return(RedirectToAction("Categories", "Admin"));
            }

            else
            {
                return(View(obj));
            }
        }
コード例 #19
0
        public ActionResult EditCare(CareViewModel obj, HttpPostedFileBase Image)
        {
            if (ModelState.IsValid)
            {
                if (Image != null)
                {
                    obj.ImageMimeType = Image.ContentType;
                    obj.ImageData     = new byte[Image.ContentLength];
                    Image.InputStream.Read(obj.ImageData, 0, Image.ContentLength);
                }
                Care p = Mapper.Map <Care>(obj);
                carerepo.SaveProduct(p);
                TempData["message"] = String.Format("Изменения в товаре '{0}' сохранены", obj.ProductName);
                return(RedirectToAction("ShowProductsInCategory", "Admin", new { obj.CategoryId }));
            }

            else
            {
                return(View(obj));
            }
        }
コード例 #20
0
ファイル: ReadCare.cs プロジェクト: hightouch67/Adam
        public ObservableCollection <Care> GetAllCare(int id)
        {
            ObservableCollection <Care> carecollection = new ObservableCollection <Care>();

            string uriPath   = "file:///C:/CM/Patients/" + id;
            string localPath = new Uri(uriPath).LocalPath;
            bool   exists    = Directory.Exists(localPath);

            if (exists)
            {
                List <string> lstFileNames = new List <string>(Directory.EnumerateFiles(localPath, "care.json"));

                foreach (string fileName in lstFileNames)
                {
                    string json;
                    json = File.ReadAllText(fileName);
                    var objects = JArray.Parse(json);
                    foreach (JObject root in objects)
                    {
                        if (root.HasValues)
                        {
                            Care care = new Care();
                            care.careId                = (int)root["careId"];
                            care.careName              = (string)root["careName"];
                            care.carePic1              = (string)root["carePic1"];
                            care.carePic2              = (string)root["carePic2"];
                            care.careFunction          = (string)root["careFunction"];
                            care.carePrescriptor       = (string)root["carePrescriptor"];
                            care.carePoso              = (string)root["carePoso"];
                            care.careDuring            = (string)root["careDuring"];
                            care.careEndDate           = (string)root["careEndDate"];
                            care.careSecondaryEffect   = (string)root["careSecondaryEffect"];
                            care.careComplementaryInfo = (string)root["careComplementaryInfo"];
                            carecollection.Add(care);
                        }
                    }
                }
            }
            return(carecollection);
        }
コード例 #21
0
        public JsonResult InsertCare()
        {
            Care c = new Care();

            c.DisplayEarNum = Request.Form["DisplayEarNum"];
            c.Disease_Id    = Convert.ToInt32(Request.Form["diseases"]);
            c.Prescription  = Request.Form["Prescription"];
            c.Date          = DateTime.Now;
            c.LeftFront     = Convert.ToInt32(Request.Form["pLeftFront"]);
            c.RightFront    = Convert.ToInt32(Request.Form["pRightFront"]);
            c.LeftBack      = Convert.ToInt32(Request.Form["pLeftBack"]);
            c.RightBack     = Convert.ToInt32(Request.Form["pRightBack"]);

            c.EarNum   = CowBLL.ConvertDislayEarNumToEarNum(c.DisplayEarNum, UserBLL.Instance.CurrentUser.Pasture.ID);
            c.DoctorID = UserBLL.Instance.CurrentUser.ID;

            bllMedical.InsertCare(c);
            CowBLL bllCow = new CowBLL();

            bllCow.UpdateCowIllStatus(c.EarNum, true);
            return(Json(new { Result = 1 }, JsonRequestBehavior.AllowGet));
        }
コード例 #22
0
        public async Task <IActionResult> Create([FromBody] Care care)
        {
            await _context.CreateNewCareAsync(care);

            return(Ok(care.Id));
        }
コード例 #23
0
ファイル: CareRepository.cs プロジェクト: antonreznik/Shop
        //----------------------------------------------------------


        //----------------------------------------------------------
        //Удаление товара
        public void DeleteProduct(Care obj)
        {
            context.Cares.Remove(obj);
            context.SaveChanges();
        }
コード例 #24
0
 public void AddCareToCareCollection(Care care)
 {
     careCollection.Add(care);
 }
コード例 #25
0
 public async Task CreateNewCareAsync(Care care)
 {
     care.OpenTime = DateTime.Now;
     await _careCollection.InsertOneAsync(care);
 }
コード例 #26
0
        private void SaveCare()
        {
            Care oldcare = new Care();

            oldcare = careCollection.Where(x => x.careId == currentCare).FirstOrDefault();
            if (oldcare != null)
            {
                string hashcode = txtbName.Text + txtbLastName.Text;
                int    code     = hashcode.GetHashCode();
                oldcare.careId                = code;
                oldcare.careName              = txtbCareName.Text;
                oldcare.careFunction          = txtbCareFunction.Text;
                oldcare.carePrescriptor       = txtbPrescriptor.Text;
                oldcare.carePoso              = txtbPoso.Text;
                oldcare.careDuring            = txtbCareDuring.Text;
                oldcare.careEndDate           = txtbCareEnd.Text;
                oldcare.careSecondaryEffect   = txtbSecondaryEffects.Text;
                oldcare.careComplementaryInfo = txtbComplementaryInfo.Text;
                DateTime compared = new DateTime();
                compared = Convert.ToDateTime("0001-01-01T00:00:00");
                string subPath = @"c:\CM\Patients\" + currentUser.ToString() + "\therapists" + oldcare.careId;
                bool   exists  = Directory.Exists(subPath);

                if (!exists)
                {
                    Directory.CreateDirectory(subPath);
                }
                string imgpath = @"c:\CM\Patients\" + currentUser.ToString() + "\therapists" + oldcare.careId + " " + Guid.NewGuid() + ".png";
                if (imgPhoto.Source != null)
                {
                    SaveToPng(imgPhoto, imgpath);
                }
                oldcare.carePic1 = imgpath;
                therapistCollection.Clear();
                AddCareToCareCollection(oldcare);
                SaveCollectionToFile(therapistCollection, @"c:\CM\Patients\" + currentUser.ToString() + "\\" + oldcare.careId + ".json");
            }
            else
            {
                Care   newcare  = new Care();
                string hashcode = txtbName.Text + txtbLastName.Text;
                int    code     = hashcode.GetHashCode();
                newcare.careId                = code;
                newcare.careName              = txtbCareName.Text;
                newcare.careFunction          = txtbCareFunction.Text;
                newcare.carePrescriptor       = txtbPrescriptor.Text;
                newcare.carePoso              = txtbPoso.Text;
                newcare.careDuring            = txtbCareDuring.Text;
                newcare.careEndDate           = txtbCareEnd.Text;
                newcare.careSecondaryEffect   = txtbSecondaryEffects.Text;
                newcare.careComplementaryInfo = txtbComplementaryInfo.Text;
                //newTherapist.patientsList.Add(currentUser.ToString());e

                DateTime compared = new DateTime();
                compared = Convert.ToDateTime("0001-01-01T00:00:00");
                //if (newcare.therapistCreationDate == compared)
                //{
                //    newcare.therapistCreationDate = DateTime.Now;
                //}
                //newTherapist.therapistLastModificationDate = DateTime.Now;
                string subPath = @"c:\CM\Patients\" + currentUser.ToString() + "\\" + newcare.careId;

                bool exists = Directory.Exists(subPath);

                if (!exists)
                {
                    Directory.CreateDirectory(subPath);
                }

                string imgpath  = @"c:\CM\Patients\" + currentUser.ToString() + "\\" + newcare.careName + " " + Guid.NewGuid() + ".png";
                string imgpath2 = @"c:\CM\Patients\" + currentUser.ToString() + "\\" + newcare.careName + " " + Guid.NewGuid() + ".png";

                if (imgPhoto1.Source != null)
                {
                    SaveToPng(imgPhoto1, imgpath);
                }
                if (imgPhoto2.Source != null)
                {
                    SaveToPng(imgPhoto2, imgpath2);
                }
                newcare.carePic1 = imgpath;
                newcare.carePic2 = imgpath2;
                AddCareToCareCollection(newcare);
                SaveCollectionToFile(careCollection, @"c:\CM\Patients\" + currentUser.ToString() + "\\care.json");
                careCollection.Clear();
            }
        }