Exemplo n.º 1
0
        public ActionResult CatCreate(FormCollection catData)
        {
            try
            {
                //고유아이디/이름/나이/성별/중성화상태/사진/상태메모
                string catName = Request.Form["catName"];
                string catAge = Request.Form["catAge"];
                string catGender = Request.Form["catGender"];
                string catNetu = Request.Form["catNetu"];
                string catMemo = Request.Form["catMemo"];
                string catURL = Request.Form["catURL"];

                CatModel newCat = new CatModel();
                newCat.catName = catName;
                newCat.catAge = Convert.ToInt32(catAge);
                newCat.catMemo = catMemo;
                newCat.catPhotoURL = catURL;
                // 수컷인지 암컷인지 판별
                if (catGender.Equals("male"))
                {
                    // 수컷이면
                    newCat.catGender = 1;
                }
                else
                {
                    // 암컷이면
                    newCat.catGender = 0;
                }
                // 중성화 여부 판별
                if (catNetu.Equals("yes"))
                {
                    newCat.catNeuter = 1;
                }
                else
                {
                    newCat.catNeuter = 0;
                }
                bool finalQueryResult = repository.Add(newCat);
                if (finalQueryResult)
                {
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    Response.Write("<script language='javascript' type='text/javascript'>alert('고양이 등록에 실패했습니다. 다시 실행해 주세요.');</script>");
                    throw new Exception();
                }
            }
            catch
            {
                return RedirectToAction("Index", "Home");
            }
        }
Exemplo n.º 2
0
 // 고양이 정보를 업데이트 한다.
 public bool Update(CatModel catItem)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 3
0
 // 고양이 추가
 public bool Add(CatModel catItem)
 {
     bool queryResult = dbConn.CatInsertToDB(catItem);
     return queryResult;
 }