Esempio n. 1
0
        public ActionResult EditVakansiyaSave(VakansiyaModel VM, int KolChel)
        {
            if (ModelState.IsValid)
            {
                var Vak = ugtu_db.Vakans.Where(vakans => vakans.idVakans == VM.ID).Single();

                // V.VakansName = VM.VakansName;
                Vak.idDolznost = (int)AddDolgnost(VM.Dolgnost);
                Vak.idPredpr = GetIdPredpr(VM.NamePred);
                Vak.DataPostVakans = VM.DataPostVakans;
                Vak.KolChel = KolChel;
                Vak.DolgnostnObyazan = VM.DolgnObyaz;
                Vak.InfoGrafikRab = VM.InfoGrafikRab;
                Vak.DopInfo = VM.DopInfo;
                Vak.Lgoty = VM.Lgoty;
                Vak.idStatus = VM.idStatus;
                Vak.DataObzvon = VM.DataObzvon;
                Vak.TrebKandidat = VM.TrebKandidat;
                Vak.ZarPlata = VM.Zarplata;
                Vak.OtdelName = VM.OtdelName;
                var ParVakans = ugtu_db.Param_Vakans.Where(vakans => vakans.idVakans == VM.ID && vakans.idParam == idParamTipZan);
                foreach (var PV in ParVakans)
                {
                    PV.idParamZnachVakans = VM.idTipZan;
                }
                var SpecsVakans = ugtu_db.Vakans_Specs.Where(vakans => vakans.idVakans == VM.ID).ToList();
                foreach (var c in SpecsVakans)
                {
                    ugtu_db.Vakans_Specs.DeleteOnSubmit(c);
                }
                ugtu_db.SubmitChanges();
                for (int j = 0; j < VM.specs.Count(); j++)
                {
                    if (VM.specs[j].ValSpec)
                    {
                        Vakans_Specs VS = new Vakans_Specs()
                        {
                            idSpecs = VM.specs[j].idSpec,
                            idVakans = VM.ID
                        };
                        ugtu_db.Vakans_Specs.InsertOnSubmit(VS);
                    }
                }
                ugtu_db.SubmitChanges();

                //if (VM.Specs.Count() == SpecsVakans.Count())
                //{
                //    int i = 0;
                //    foreach(var c in SpecsVakans)
                //    {
                //        c.idSpecs = VM.Specs[i];
                //        c.idVakans = VM.ID;
                //        i++;
                //    }
                //}

                //if (VM.Specs.Count() > SpecsVakans.Count())
                //{
                //    int i = 0;
                //    foreach (var c in SpecsVakans)
                //    {
                //        c.idSpecs = VM.Specs[i];
                //        c.idVakans = VM.ID;
                //        i++;
                //    }
                //    for (int j = 0; j < VM.Specs.Count() - SpecsVakans.Count(); j++)
                //    {
                //        Vakans_Specs VS = new Vakans_Specs()
                //        {
                //            idSpecs = VM.Specs[j+i],
                //            idVakans = VM.ID
                //        };
                //        ugtu_db.Vakans_Specs.InsertOnSubmit(VS);
                //    }
                //}

                //if (VM.Specs.Count() < SpecsVakans.Count())
                //{
                //    for (int j = 0; j < SpecsVakans.Count()-VM.Specs.Count(); j++)
                //    {
                //        ugtu_db.Vakans_Specs.DeleteOnSubmit(SpecsVakans.ToList()[j]);
                //    }
                //    for (int j = 0; j <  VM.Specs.Count(); j++)
                //    {
                //        SpecsVakans.ToList()[j].idSpecs = VM.Specs[j];
                //        SpecsVakans.ToList()[j].idVakans = VM.ID;
                //    }
                //}

                return RedirectToAction("VakansiyaInfo", new { id = VM.ID });
            }
            else { return RedirectToAction("VakansiyaEdit", new { id = VM.ID }); };
        }
Esempio n. 2
0
        public ActionResult AddVakansiyaSave(VakansiyaModel VM, int KolChel)
        {
            if (ModelState.IsValid)
            {

                //DateTime DataObzvon = VM.DataPostVakans;
                int Status = 1;//открыта
                int? lastid = null;
                Vakans res = new Vakans()
                {
                    // VakansName = VM.VakansName,
                    idPredpr = GetIdPredpr(VM.NamePred),
                    DolgnostnObyazan = VM.DolgnObyaz,
                    InfoGrafikRab = VM.InfoGrafikRab,
                    Lgoty = VM.Lgoty,
                    DopInfo = VM.DopInfo,
                    DataPostVakans = VM.DataPostVakans,
                    DataObzvon = VM.DataPostVakans,// костыль
                    idDolznost = (int)AddDolgnost(VM.Dolgnost),
                    idStatus = Status,
                    KolChel = KolChel,
                    TrebKandidat = VM.TrebKandidat,
                    ZarPlata = VM.Zarplata,
                    OtdelName = VM.OtdelName
                };
                ugtu_db.Vakans.InsertOnSubmit(res);
                ugtu_db.SubmitChanges();
                lastid = res.idVakans;
                Param_Vakans PV = new Param_Vakans()
                    {
                        idParamZnachVakans = VM.idTipZan,
                        idParam =
                            ugtu_db.ZnachParam.Where(param => param.idZnachParam == VM.idTipZan)
                                   .Select(param => param.idParam)
                                   .First(),
                        idVakans = (int)lastid
                    };
                ugtu_db.Param_Vakans.InsertOnSubmit(PV);
                ugtu_db.SubmitChanges();
                for (int i = 0; i < VM.specs.Count(); i++)
                {
                    if (VM.specs[i].ValSpec)
                    {
                        Vakans_Specs VS = new Vakans_Specs()
                        {
                            idSpecs = VM.specs[i].idSpec,
                            idVakans = (int)lastid
                        };
                        ugtu_db.Vakans_Specs.InsertOnSubmit(VS);
                        ugtu_db.SubmitChanges();
                    }
                }

                return RedirectToAction("VakansiyaInfo", new { id = res.idVakans });
            }
            else { return RedirectToAction("AddVakansiya"); }
        }
Esempio n. 3
0
 partial void DeleteVakans_Specs(Vakans_Specs instance);
Esempio n. 4
0
 partial void UpdateVakans_Specs(Vakans_Specs instance);
Esempio n. 5
0
 partial void InsertVakans_Specs(Vakans_Specs instance);
Esempio n. 6
0
		private void detach_Vakans_Specs(Vakans_Specs entity)
		{
			this.SendPropertyChanging();
			entity.Vakans = null;
		}
Esempio n. 7
0
		private void attach_Vakans_Specs(Vakans_Specs entity)
		{
			this.SendPropertyChanging();
			entity.Vakans = this;
		}