Esempio n. 1
0
        public ActionResult Audio(Guid bandId)
        {
            var model = new EditAudioModel
            {
                Audio = DataRepository.GetAudioByBand(bandId)
            };

            return(View(model));
        }
Esempio n. 2
0
        public JsonResult Edit(EditAudioModel model)
        {
            var objectId = ObjectId.GenerateNewId();

            if (!string.IsNullOrEmpty(model.ID) && !ObjectId.TryParse(model.ID, out objectId))
            {
                return(Json(new
                {
                    Code = 300,
                    Msg = "ID不合法。"
                }));
            }

            if (string.IsNullOrEmpty(model.Name))
            {
                return(Json(new
                {
                    Code = 300,
                    Msg = "名称不允许为空。"
                }));
            }

            var mongo = new MongoHelper();

            var pinyin = PinYinHelper.GetTotalPinYin(model.Name);

            var filter = Builders <BsonDocument> .Filter.Eq("ID", objectId);

            var update1 = Builders <BsonDocument> .Update.Set("Name", model.Name);

            var update2 = Builders <BsonDocument> .Update.Set("TotalPinYin", pinyin.TotalPinYin);

            var update3 = Builders <BsonDocument> .Update.Set("FirstPinYin", pinyin.FirstPinYin);

            var update = Builders <BsonDocument> .Update.Combine(update1, update2, update3);

            mongo.UpdateOne(Constant.AudioCollectionName, filter, update);

            return(Json(new
            {
                Code = 200,
                Msg = "保存成功!"
            }));
        }